SMS
— A simple SMS client¶
This module provides “.text-<name> <message>” commands that send SMS messages via the Twilio api.
Config¶
{
"account_sid": "xxxx",
"auth_token": "xxxx",
"number": "+10000000000",
"api_port": 3000,
"channel": "#foo",
"contacts": {
"guy1": "+11111111111",
"guy2": "+12222222222"
},
"limit": {
"enable": true,
"period": 900,
"max": 5
}
}
-
account_sid
¶
Twilio account ID
-
auth_token
¶
Twilio auth token
-
number
¶
Twilio phone number. Must match the format shown above.
-
api_port
¶
HTTP port to listen for Twilio webhook requests on. Using -1 disables webhook listening.
-
channel
¶
Channel the module is enabled on
-
contacts
¶
Dict of names to phone numbers. Names must be a-zA-Z0-9 and numbers match the format shown above.
-
limit.enable
¶
Enable or disable rate limiting. Rate limiting is controlled as a “burst bucket.” If enabled, sending an SMS requires 1 and removes one point from the bucket.
-
limit.period
¶
Every limit.period, a virtual point is added to the bucket.
-
limit.max
¶
When adding a point the bucket, the point will be discarded if the bucket already has limit.max points.
Twilio Setup¶
In Twilio’s UI, create a “Messaging Service” of the “Notifications, 2-Way” type. Check “Process inbound messages” if desired and enter the bot’s webhook URL.
The webhook listener listens on /app/gotsms, so an example webhook URL would be http://1.2.3.4:3000/app/gotsms.
Class Reference¶
-
class
pyircbot.modules.SMS.
SMS
(bot, moduleName)[source]¶ Bases:
pyircbot.modulebase.ModuleBase
-
check_rate_limit
()[source]¶ Rate limiting via a ‘burst bucket’. This method is called before sending and returns true or false depending on if the action is allowed.
-