Esempio n. 1
0
    def testCommandParsing(self):
        botname = 'friendbiz'
        tweet = 'test5 appl mandarin'
        twitterData = {}
        twitterData['text'] = '@' + botname + ' ' + tweet
        twitterData['user'] = {}
        twitterData['user']['screen_name'] = 'blobby914'
        config = self.getConfig(botname)

        event = parsing.event(twitterData, config)
        assert event.isCommand == True
        assert event.command == 'test5'
        assert event.params == ['appl', 'mandarin']
        assert event.sender == 'blobby914'
Esempio n. 2
0
    def on_data(self, twitterJson):
        twitterData = json.loads(twitterJson)

        if 'text' in twitterData:
        # get a context object with useful information appended, and unuseful information removed.
            event = parsing.event(twitterData, self.config)
            if event.isCommand:
                print("Attempting to dispatch command " + event.command + " from " + event.sender)
                self.command._dispatch(event.command, event.params, event.sender)
            else:
                print("Not command")
                print(twitterData['text'] + "\n" + twitterData['user']['screen_name'] + ' : ' + twitterData['created_at'])

        return True