diff options
author | Florent Le Coz <louiz@louiz.org> | 2012-07-07 04:51:52 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2012-07-07 04:52:20 +0200 |
commit | 8739662e311a97839dececf7817d9ff12701dd5e (patch) | |
tree | ffc5445bde64ba156c3613617e704d27039efe95 /doc/en | |
parent | ab14923611a438386822598e2fc24b4efa00d282 (diff) | |
download | poezio-8739662e311a97839dececf7817d9ff12701dd5e.tar.gz poezio-8739662e311a97839dececf7817d9ff12701dd5e.tar.bz2 poezio-8739662e311a97839dececf7817d9ff12701dd5e.tar.xz poezio-8739662e311a97839dececf7817d9ff12701dd5e.zip |
Add a replace plugin.
Diffstat (limited to 'doc/en')
-rw-r--r-- | doc/en/plugins/replace.txt | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/doc/en/plugins/replace.txt b/doc/en/plugins/replace.txt new file mode 100644 index 00000000..3a17ff20 --- /dev/null +++ b/doc/en/plugins/replace.txt @@ -0,0 +1,71 @@ +Replace +======= + +Replace some patterns in a message before sending it. + + +Installation +------------ +You only have to load the plugin. + +============== + + /load replace + +============== + +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 everytime you’re angry, you can create a +curse pattern this way: + +- In the init(self) method of the Plugin class, add something like + +================ +[source,python] + self.patterns['curse'] = replace_curse +================ + +- then define a function (not a method of the Plugin class) at the bottom +of the file. For example: + + +========================================================== +[source,python] +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 conveniance, you can read your nice words from a file, do whatever +you want in that function, as long as it returns a string. |