Source code for athena.modules.active.twitter
"""
Allows users to send tweets via voice command
Requires:
- IFTTT configuration
Usage Examples:
- "Tweet What's up guys?"
- "Post What's up everyone? to twitter"
"""
from athena.classes.module import Module
from athena.classes.task import ActiveTask
from athena.api_library import ifttt_api as ifttt
MOD_PARAMS = {
'name': 'twitter',
'priority': 2,
}
[docs]class SendTweetTask(ActiveTask):
def __init__(self):
super().__init__(patterns=[r'.*\btweet (.*)',
r'.*\bpost (.*)\bto twitter\b.*'])
self.groups = {1: 'tweet'}
[docs] def action(self, text):
self.speak('Sending tweet...', show_text=True)
ifttt.trigger('voice_tweet', self.tweet)
[docs]class Twitter(Module):
def __init__(self):
tasks = [SendTweetTask()]
super().__init__(MOD_PARAMS, tasks)