]> jfr.im git - erebus.git/blob - modules/sms.py
control - be aware of dependents
[erebus.git] / modules / sms.py
1 # Erebus IRC bot - Author: Erebus Team
2 # simple module example
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': [1], # compatible module API versions
10 'depends': [], # other modules required to work properly?
11 }
12
13 # preamble
14 import modlib
15 lib = modlib.modlib(__name__)
16 modstart = lib.modstart
17 modstop = lib.modstop
18
19 # module code
20 from twilio.rest import TwilioRestClient
21
22 def client(bot):
23 return TwilioRestClient(
24 bot.parent.cfg.get('sms', 'account_sid'),
25 bot.parent.cfg.get('sms', 'auth_token')
26 )
27
28
29 @lib.hook(needchan=False, glevel=lib.MANAGER)
30 def reply(bot, user, chan, realtarget, *args):
31 raise NotImplementedError
32
33 @lib.hook(('sms','w'), needchan=False, glevel=lib.OWNER)
34 @lib.help("<number> <message>", "send an SMS")
35 def sms(bot, user, chan, realtarget, *args):
36 number = "+%s" % (args[0])
37 message = ' '.join(args[1:])
38 client(bot).messages.create(body=message, to=number, from_=bot.parent.cfg.get('sms', 'mynumber'))
39 bot.msg(user, "Sent message to %s" % (number))