1 """
2 Send a help message
3
4 @copyright: (c) 2011 hackmeeting U{http://sindominio.net/hackmeeting}
5 @author: Ruben Pollan
6 @organization: hackmeeting U{http://sindominio.net/hackmeeting}
7 @contact: meskio@sindominio.net
8 @license:
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the Do What The Fuck You Want To
11 Public License, Version 2, as published by Sam Hocevar. See
12 U{http://sam.zoy.org/projects/COPYING.WTFPL} for more details.
13 """
14
15 from emma.events import Event, subscribe, trigger, run_event
16 from emma.module import Module
17 from emma.interface.message import Message
18
19
24
26 cmd, args = data[0]
27
28
29 if cmd not in ('help', _('help')):
30 return
31
32
33 event.event = 'help'
34 help_strs = set(run_event(event, args))
35 help_strs -= set([""])
36 if help_strs:
37 if not args:
38 body = _("emma is a bot for virtual assembly\n" \
39 "==================================\n" \
40 "Commands:\n")
41 else:
42 body = ""
43 body += '\n'.join(help_strs)
44 else:
45 body = _("No help")
46
47 event.event = 'send'
48 to = data[1]['From']
49 if event.interface == 'irc' and data[1]['To'][0] == '#':
50 to = data[1]['To']
51 msg = Message(body, to)
52 msg['Subject'] = _("help")
53 trigger(event, msg)
54