]>
Commit | Line | Data |
---|---|---|
7e64e1a2 | 1 | # Erebus IRC bot - Author: Erebus Team |
a62d0d18 | 2 | # twilio sms module |
7e64e1a2 | 3 | # This file is released into the public domain; see http://unlicense.org/ |
4 | ||
5 | # module info | |
6 | modinfo = { | |
7 | 'author': 'Erebus Team', | |
8 | 'license': 'public domain', | |
f5aec865 | 9 | 'compatible': [2], |
a62d0d18 | 10 | 'depends': [], |
11 | 'softdeps': ['help'], | |
7e64e1a2 | 12 | } |
13 | ||
14 | # preamble | |
15 | import modlib | |
16 | lib = modlib.modlib(__name__) | |
17 | modstart = lib.modstart | |
18 | modstop = lib.modstop | |
19 | ||
20 | # module code | |
21 | from twilio.rest import TwilioRestClient | |
22 | ||
23 | def client(bot): | |
24 | return TwilioRestClient( | |
25 | bot.parent.cfg.get('sms', 'account_sid'), | |
26 | bot.parent.cfg.get('sms', 'auth_token') | |
27 | ) | |
28 | ||
29 | ||
3c23ab38 | 30 | @lib.hook(needchan=False, glevel=lib.MANAGER) |
7e64e1a2 | 31 | def reply(bot, user, chan, realtarget, *args): |
3c23ab38 | 32 | raise NotImplementedError |
7e64e1a2 | 33 | |
34 | @lib.hook(('sms','w'), needchan=False, glevel=lib.OWNER) | |
5f03d045 | 35 | @lib.help("<number> <message>", "send an SMS") |
7e64e1a2 | 36 | def sms(bot, user, chan, realtarget, *args): |
37 | number = "+%s" % (args[0]) | |
38 | message = ' '.join(args[1:]) | |
39 | client(bot).messages.create(body=message, to=number, from_=bot.parent.cfg.get('sms', 'mynumber')) | |
40 | bot.msg(user, "Sent message to %s" % (number)) |