]> jfr.im git - erebus.git/blob - modules/sms.py
revert apiversion to 0
[erebus.git] / modules / sms.py
1 # Erebus IRC bot - Author: Erebus Team
2 # twilio sms module
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',
9 'compatible': [0],
10 'depends': [],
11 'softdeps': ['help'],
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
30 @lib.hook(needchan=False, glevel=lib.MANAGER)
31 def reply(bot, user, chan, realtarget, *args):
32 raise NotImplementedError
33
34 @lib.hook(('sms','w'), needchan=False, glevel=lib.OWNER)
35 @lib.help("<number> <message>", "send an SMS")
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))