-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathexample_plugin.py
More file actions
63 lines (53 loc) · 2.4 KB
/
example_plugin.py
File metadata and controls
63 lines (53 loc) · 2.4 KB
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
from plugin import *
@doc("this is what you will see as plugin's help")
class example_plugin(plugin):
def __init__(self, bot):
super().__init__(bot)
def unload_plugin(self):
# you should unload your plugin in this method
# usually you don't need to implement this
pass
def assert_config(self):
# assert config compatibility here
# should throw if config is invalid
# in such case, plugin won't be loaded
pass
@command
@command_alias('put_command', 'aliases_here')
def example_command(self, sender_nick, args, **kwargs):
self.logger.info(f'example command called by {sender_nick} with {args}')
self.bot.say('example command called!')
self.bot.say(f'{color.red("whoa, red answer")} and normal one')
self.bot.say('private msg', sender_nick)
# you can easily access everything you need from self.bot
# you can access plugin's config file section via self.config and whole config via self.bot.config
# self.config is simply self.bot.config['your_plugin_name']
#
# every command should take **kwargs argument(!) and positional ones as needed:
# sender_nick - nickname of msg sender
# args - ['some', 'arguments', 'passed', 'to', 'plugin']
# msg - 'some arguments passes to plugin '
# raw_msg - raw IRC msg
def on_pubmsg(self, raw_msg, **kwargs):
# see plugin base class methods for more on_* methods
#
# every on_* method should take **kwargs argument(!) and positional ones as needed
# see plugin base class for possible positional arguments
pass
@command(admin=True)
def example_admin_command(self, sender_nick, **kwargs):
# you need admin privileges to call this command
pass
@command(superadmin=True)
def example_superadmin_command(self, sender_nick, **kwargs):
# you need superadmin privileges to call this command
pass
@command(channel_op=True)
def example_channel_op_command(self, sender_nick, **kwargs):
# you need to be channel operator to call this command
pass
@command
@doc("this is what you will see as command's help")
def example_command_with_doc(self, sender_nick, **kwargs):
# try '.help example_command_with_doc' to see "this is what you will see as command's help"
pass