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 This module contains examples of how to create your own commands, by
29 creating a new command container, bounded to a specific command host,
30 and definding a set of commands inside of it.
31
32 Keep in mind that this module is not being loaded from anywhere, so the
33 code in here will not be executed and commands defined here will not be
34 detected.
35 """
36
37 from ..framework import CommandContainer, command, doc
38 from hosts import *
41 """
42 The AUTOMATIC class variable, set to a positive value, instructs the
43 command system to automatically discover the command container and
44 enable it.
45
46 This command container bounds to all three available in the default
47 implementation command hosts. This means that commands defined in
48 this container will be available to all: chat, private chat and a
49 group chat.
50 """
51
52 AUTOMATIC = True
53 HOSTS = ChatCommands, PrivateChatCommands, GroupChatCommands
54
55 @command
57 """
58 First line of the doc string is called a description and will be
59 programmatically extracted and formatted.
60
61 After that you can give more help, like explanation of the
62 options. This one will be programatically extracted and
63 formatted too.
64
65 After all the documentation - there will be autogenerated (based
66 on the method signature) usage information appended. You can
67 turn it off, if you want.
68 """
69 return "I don't dance."
70
72 """
73 This command container bounds only to the ChatCommands command host.
74 Therefore commands defined inside of the container will be available
75 only to a chat.
76 """
77
78 AUTOMATIC = True
79 HOSTS = ChatCommands,
80
81 @command("squal", "bawl")
83 """
84 This command has an additional aliases. It means the command will
85 be available under three names: sing (the native name), squal
86 (the first alias), bawl (the second alias).
87
88 You can turn off the usage of the native name, if you want, and
89 specify a name or a set of names, as aliases, under which a
90 command will be available.
91 """
92 return "Buy yourself a stereo."
93
95 """
96 This command container bounds only to the PrivateChatCommands
97 command host. Therefore commands defined inside of the container
98 will be available only to a private chat.
99 """
100
101 AUTOMATIC = True
102 HOSTS = PrivateChatCommands,
103
104 @command
105 @doc(_("The same as using a doc-string, except it supports translation"))
107 return "I'm not a coffee machine!"
108
110 """
111 This command container bounds only to the GroupChatCommands command
112 host. Therefore commands defined inside of the container will be
113 available only to a group chat.
114 """
115
116 AUTOMATIC = True
117 HOSTS = GroupChatCommands,
118
119 @command
121 return "Buy yourself a dog."
122