class ToggleModuleTask(ActiveTask):

    disable_triggers = {
        'en-US': ['disable', 'remove'],
        'is': ['af(?:virkja|tengja)', 'fjarlægja']
    }

    triggers = {
        'en-US': [
            r'.*\b(enable|add|{}) (.*)'.format('|'.join(
                get_from_dict(disable_triggers, ENABLED)))
        ],
        'is': [
            r'.*\b(virkja|tengja|bæta við|{}) (.*)'.format('|'.join(
                get_from_dict(disable_triggers, ENABLED)))
        ]
    }

    def __init__(self):
        super(ToggleModuleTask,
              self).__init__(patterns=get_from_dict(self.triggers, ENABLED))
        self.groups = {1: 'enable', 2: 'module'}

    def match(self, text):
        return self.match_and_save_groups(text, self.groups)

    def action(self, text):
        mod_name = self.module.lower().strip().replace(' ', '')

        should_disable = False
        for disable_trigger in get_from_dict(self.disable_triggers, ENABLED):
            if disable_trigger in self.enable.lower():
                should_disable = True
                break

        if should_disable:
            log.info("Attempting to disable '" + mod_name + "'")
            disable = mods.disable_mod(mod_name)
            self.speak(disable)
        else:
            log.info("Attempting to enable '" + mod_name + "'")
            enable = mods.enable_mod(mod_name)
            self.speak(enable)
    def action(self, text):
        mod_name = self.module.lower().strip().replace(' ', '')

        should_disable = False
        for disable_trigger in get_from_dict(self.disable_triggers, ENABLED):
            if disable_trigger in self.enable.lower():
                should_disable = True
                break

        if should_disable:
            log.info("Attempting to disable '" + mod_name + "'")
            disable = mods.disable_mod(mod_name)
            self.speak(disable)
        else:
            log.info("Attempting to enable '" + mod_name + "'")
            enable = mods.enable_mod(mod_name)
            self.speak(enable)
 def __init__(self):
     super(ToggleModuleTask,
           self).__init__(patterns=get_from_dict(self.triggers, ENABLED))
     self.groups = {1: 'enable', 2: 'module'}
 def __init__(self):
     super(ListModulesTask,
           self).__init__(words=get_from_dict(self.triggers, ENABLED))
示例#5
0
 def __init__(self):
     super(VoiceBrowseTask,
           self).__init__(patterns=get_from_dict(self.triggers, ENABLED))
     self.groups = {1: 'group1'}
 def __init__(self):
     super(QuitTask,
           self).__init__(patterns=get_from_dict(self.triggers, ENABLED))
示例#7
0
 def __init__(self):
     super(SendTextTask,
           self).__init__(patterns=get_from_dict(self.triggers, ENABLED))
     self.groups = {1: 'msg'}
示例#8
0
 def action(self, text):
     self.speak(get_from_dict(self.response, ENABLED, is_response=True))
     play_mp3(TURN_UP_SONG)
示例#9
0
 def action(self, text):
     print('\n~ Tweet: ' + self.tweet)
     self.speak(get_from_dict(self.response, ENABLED, is_response=True),
                show_text=True)
     ifttt.trigger('voice_tweet', self.tweet)
示例#10
0
 def action(self, text):
     self.speak(get_from_dict(self.response, ENABLED, is_response=True))
示例#11
0
 def __init__(self):
     # Matches any statement with these words
     super(SpeakPhrase,
           self).__init__(words=get_from_dict(self.triggers, ENABLED))