summaryrefslogtreecommitdiff
path: root/doc/en/plugins/replace.txt
blob: 3a17ff20e20d1d37667a128d584cbd8ce5f2c5b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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.