]>
jfr.im git - erebus.git/blob - 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/
7 'author': 'Erebus Team',
8 'license': 'public domain',
9 'compatible': [1], # compatible module API versions
10 'depends': [], # other modules required to work properly?
15 lib
= modlib
.modlib(__name__
)
16 modstart
= lib
.modstart
20 from twilio
.rest
import TwilioRestClient
23 return TwilioRestClient(
24 bot
.parent
.cfg
.get('sms', 'account_sid'),
25 bot
.parent
.cfg
.get('sms', 'auth_token')
29 @lib.hook(needchan
=False, glevel
=lib
.MANAGER
)
30 def reply(bot
, user
, chan
, realtarget
, *args
):
31 raise NotImplementedError
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
))