added the tweet task for alerting via twitter
This commit is contained in:
parent
4b2513bfca
commit
9b38c424f8
1 changed files with 28 additions and 0 deletions
28
lib/tasks/tweet.py
Normal file
28
lib/tasks/tweet.py
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
"""
|
||||||
|
The tweet/twitter task.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import twitter
|
||||||
|
from lib.tasks.task import Task
|
||||||
|
|
||||||
|
|
||||||
|
class TweetTask(Task):
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
if not "type" in kwargs:
|
||||||
|
raise Exception("'type' not in typeDict " + str(kwargs))
|
||||||
|
if not "args" in kwargs:
|
||||||
|
raise Exception("typeDict " + str(kwargs) + " has no arguments!")
|
||||||
|
self.set_task_type(kwargs["type"])
|
||||||
|
self.recipient = kwargs["args"]["rcpt"]
|
||||||
|
|
||||||
|
def execute(self, msg):
|
||||||
|
api = twitter.Api(consumer_key='consumer_key',
|
||||||
|
consumer_secret='consumer_secret',
|
||||||
|
access_token_key='access_token',
|
||||||
|
access_token_secret='access_token_secret')
|
||||||
|
status = api.PostUpdate(msg)
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def create(taskDict):
|
||||||
|
return TweetTask(**taskDict)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue