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