]> jfr.im git - erebus.git/blame - modules/sms.py
admin_config - add !getconfig, remove some unused functions
[erebus.git] / modules / sms.py
CommitLineData
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
7modinfo = {
8 'author': 'Erebus Team',
9 'license': 'public domain',
fa93b933 10 'compatible': [0],
a62d0d18 11 'depends': [],
12 'softdeps': ['help'],
7e64e1a2 13}
14
15# preamble
16import modlib
17lib = modlib.modlib(__name__)
18modstart = lib.modstart
19modstop = lib.modstop
20
21# module code
22from twilio.rest import TwilioRestClient
23
24def client(bot):
25 return TwilioRestClient(
26 bot.parent.cfg.get('sms', 'account_sid'),
27 bot.parent.cfg.get('sms', 'auth_token')
28 )
29
30
7e64e1a2 31@lib.hook(('sms','w'), needchan=False, glevel=lib.OWNER)
5f03d045 32@lib.help("<number> <message>", "send an SMS")
7e64e1a2 33def 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))