All modules for services written in Ruby must inherit from this base class.
API
1 class ServiceModule
2 #Hook Constants
3 UMODE_HOOK
4 CMODE_HOOK
5 NEWUSER_HOOK
6 PRIVMSG_HOOK
7 JOIN_HOOK
8 NICK_HOOK
9 NOTICE_HOOK
10
11 #Log Constants
12 LOG_CRIT
13 LOG_ERROR
14 LOG_WARN
15 LOG_NOTICE
16 LOG_TRACE
17 LOG_INFO
18 LOG_DEBUG
19
20 #Command Flags
21 MFLG_SLOW
22 MFLG_UNREG
23 SFLG_UNREGOK
24 SFLG_ALIAS
25 SFLG_KEEPARG
26 SFLG_CHANARG
27 SFLG_NICKARG
28 SFLG_NOMAXPARAM
29
30 #Command Access Flags
31 USER_FLAG
32 IDNETIFIED_FLAG
33 OPER_FLAG
34 ADMIN_FLAG
35 SUDO_FLAG
36
37 def unload() end
38 def service_name(name = "") end
39 def register(commands = []) end
40 def add_hook(hooks = []) end
41 def load_language(filename = "") end
42 def join_channel(channel = "") end
43 def log(level, message) end
44 def reply_user(client, message) end
45 def reply_lang(client, id, *message) end
46 def introduce_server(server, gecos) end
47 def exit_client(client, source, reason) end
48
49 end
Usage Notes
All modules must call service_name and register, in that order.
Registering Commands
register takes an array in the following format
[ ["COMMAND", PARAM_MIN, PARAM_MAX, FLAGS, ACCESS, HLP_SHORT, HELP_LONG], ]
- "COMMAND" should be capitalized and is the name of the method to handle:
1 def COMMAND(client, parv = []) end
- PARAM_MIN number of parameters the command will accept at minimum
- PARAM_MAX number of parameters the command will accept at maximum
- FLAGS MFLG and SFLG flags
- ACCESS Who has access to the command
- Number id of the short help
- Number id of the long help
Hooking Events
add_hook takes an array in the following format
[ [HOOK_TYPE, "method name"], ]
- HOOK_TYPE is one of the hook constants
- "method name" the name of a method you've defined in your class
Unloading
If you have resources you need to clean up, clients to exit, or channels to part overload the unload method which is called when the module has been requested to be unloaded. This is crucial for 'clean' services restarts.
