poezio/doc/en/plugins/replace.txt
2012-07-07 04:52:20 +02:00

71 lines
1.5 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
dont want to search for an insult everytime youre 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.