Replace¶
Replace some patterns in a message before sending it.
Usage¶
Insert a pattern in the form
%pattern%
in your message, and it will be replaced by the corresponding text.
The list of provided patterns is:
time: Insert the current time
date: Insert the current date
datetime: Insert the current date and time
random_nick: Insert a random nick from the current MUC
dice: Insert a random number between 1 and 6
Add your own pattern¶
You can easily edit this plugin to add your own patterns. For example if don’t want to search for an insult every time you’re angry, you can create a curse pattern this way:
In the init(self) method of the Plugin class, add something like
self.patterns['curse'] = replace_curse
then define a function (not a method of the Plugin class) at the bottom of the file. For example:
def replace_curse(message, tab):
return random.choice(['dumb shit', 'idiot', 'moron'])
and you can now use something like
Shut up, %curse%!
in your everyday-conversations.
For more convenience, you can read your nice words from a file, do whatever you want in that function, as long as it returns a string.