]> jfr.im git - erebus.git/blob - modules/sms.py
admin_config - add !getconfig, remove some unused functions
[erebus.git] / modules / sms.py
1 # Erebus IRC bot - Author: Erebus Team
2 # vim: fileencoding=utf-8
3 # twilio sms module
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',
10 'compatible': [0],
11 'depends': [],
12 'softdeps': ['help'],
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
31 @lib.hook(('sms','w'), needchan=False, glevel=lib.OWNER)
32 @lib.help("<number> <message>", "send an SMS")
33 def sms(bot, user, chan, realtarget, *args):
34 number = "+%s" % (args[0])
35 message = ' '.join(args[1:])
36 client(bot).messages.create(body=message, to=number, from_=bot.parent.cfg.get('sms', 'mynumber'))
37 bot.msg(user, "Sent message to %s" % (number))