]> jfr.im git - erebus.git/commitdiff
add sms module
authorzonidjan <redacted>
Sun, 26 Mar 2017 02:24:27 +0000 (21:24 -0500)
committerzonidjan <redacted>
Sun, 26 Mar 2017 02:24:27 +0000 (21:24 -0500)
bot.config.example
modules/sms.py [new file with mode: 0644]

index c58828500050f9009892f2de5fb7c0631bb745e7..328d783b7f64d8adbb5378b846eafddb43bb9100 100644 (file)
@@ -23,3 +23,7 @@ con_sec = twitter consumer secret
 token = twitter token
 token_sec = twitter token secret
 
+[sms]
+account_sid = twilio AccountSid
+auth_token = twilio auth token
+mynumber = +11234567890 (sms "callerid")
diff --git a/modules/sms.py b/modules/sms.py
new file mode 100644 (file)
index 0000000..acf46da
--- /dev/null
@@ -0,0 +1,38 @@
+# Erebus IRC bot - Author: Erebus Team
+# simple module example
+# This file is released into the public domain; see http://unlicense.org/
+
+# module info
+modinfo = {
+       'author': 'Erebus Team',
+       'license': 'public domain',
+       'compatible': [1], # compatible module API versions
+       'depends': [], # other modules required to work properly?
+}
+
+# preamble
+import modlib
+lib = modlib.modlib(__name__)
+modstart = lib.modstart
+modstop = lib.modstop
+
+# module code
+from twilio.rest import TwilioRestClient
+
+def client(bot):
+       return TwilioRestClient(
+               bot.parent.cfg.get('sms', 'account_sid'),
+               bot.parent.cfg.get('sms', 'auth_token')
+       )
+
+
+#@lib.hook(needchan=False, glevel=lib.MANAGER)
+def reply(bot, user, chan, realtarget, *args):
+       pass
+
+@lib.hook(('sms','w'), needchan=False, glevel=lib.OWNER)
+def sms(bot, user, chan, realtarget, *args):
+       number = "+%s" % (args[0])
+       message = ' '.join(args[1:])
+       client(bot).messages.create(body=message, to=number, from_=bot.parent.cfg.get('sms', 'mynumber'))
+       bot.msg(user, "Sent message to %s" % (number))