示例#1
0
    def procCommand(self):
    
        if self.command == 'getlb':
            msrcom = srcom.srcom()
            self.output = msrcom.get_lb(' '.join(map(str,self.parms)))
            return True

        elif self.command == 'title':

            global channel

            mtwitch = Twitch()
            mtwitch.title(' '.join(map(str, self.parms)))
            return True

        elif self.command == 'game':

            global channel

            mtwitch = Twitch()
            mtwitch.game(' '.join(map(str, self.parms)))
            return True

        elif self.command == 'hi':
            self.output = 'Hello ' + self.user + '!'
            return True

        elif self.command == 'bye':
            self.killCommand = True
            self.output = 'Bye, love you!'
            return True

        elif self.command == 'fact':
            mSql = SQL.SQL()

            if not self.parms:
                fact = mSql.selectAsArray("SELECT * FROM facts ORDER BY RAND()LIMIT 0,1;", None)
                self.output = fact

            elif self.parms[0] == "add":
                ddb = DynamoDB(globals.channel.user_id)

                # TODO fact text is storing with quotes, need to strip them off
                ddb.put_fact(self.parms[1], self.parms[2])

                self.command = 'fact'
                self.parms = {self.parms[1]}
                self.procCommand()

            else:
                ddb = DynamoDB(globals.channel.user_id)

                fact = ddb.get_fact(self.parms[0])
                
                if not fact:
                    self.output = "Sorry buddy, fact not found. :("

                else:
                    self.output = fact
                    
            return True
        
        else:
            return True