示例#1
0
    def do_command(self,
                   source=AbstractCommand.CommandSource.default,
                   user: str = "User",
                   userID="0",
                   command="",
                   rest="",
                   bonusData=None):
        returnString = user + " sent a tts command!"
        praxis_logger_obj.log("\n Command>: " + command + rest)

        if "Twitch" in source:
            for name in config.allowedTTS_List:
                print(name)
                tempName = user.lower()
                if name == tempName:
                    self.send_TTS(user, rest)
                    db = utilities_db.Praxis_DB_Connection(autoConnect=True)
                    db.add_taskToQueue("standalone_discord", "voice",
                                       str(time.time()), "play",
                                       dumps({
                                           "type": "tts",
                                           "text": rest
                                       }), "")
        elif "Discord" in source:
            for name in config.allowedTTS_List:
                print(name)

                tempNick = self.contains_value("(?<=nick=')[^']+", bonusData)

                tempName = user.lower()
                if name == str(userID):
                    self.send_TTS(tempNick, rest)

                    db = utilities_db.Praxis_DB_Connection(autoConnect=True)
                    db.add_taskToQueue("standalone_discord", "voice",
                                       str(time.time()), "play",
                                       dumps({
                                           "type": "tts",
                                           "text": rest
                                       }), "")
        else:
            returnString = self.send_TTS(user, rest)

        #for name in config.allowedCommandsList_TwitchPowerUsers:
        #print(name)
        #tempName = user.lower()
        #if name == tempName:
        #self.send_TTS(user, rest)

        return returnString
示例#2
0
 def __init__(self):
     self.tokenRefreshTime: float = 60
     self.db = utilities_db.Praxis_DB_Connection()
     #self.db.connectionString = "postgresql://*****:*****@standalone_db_main/PRAXIS_BOT_DB"
     self.db.startConnection()
     self.lastAPI_Response = ""
     self.lastAPI_ResponseTime = None
示例#3
0
 def do_work(self, user, functionName, args, bonusData):
     arg: str = args[0]
     if (arg.lower() == "true"):
         arg = "true"
     db = utilities_db.Praxis_DB_Connection(autoConnect=True)
     db.add_taskToQueue("standalone_discord", "voice", str(time.time()),
                        "loop", arg, "")
     return args
示例#4
0
def create_basicCommand(commandName: str, commandReponse: str):
    db_obj = db_utility.Praxis_DB_Connection(autoConnect=True)
    if db_obj.doesTableExist("command_responses_v0") == True:
        results = db_obj.execQuery('INSERT INTO command_responses_v0 '
                                   '(command, response) '
                                   'VALUES (\'%s\',\'%s\');' %
                                   (commandName, commandReponse))
        print(results)
    db_obj.closeConnection()
示例#5
0
def db_setup():
    db_obj = db_utility.Praxis_DB_Connection(autoConnect=True)
    db_obj.dbConnection.execute('DROP TABLE command_responses_v0')
    if db_obj.doesTableExist("command_responses_v0") == False:
        print("Making Table")
        results = db_obj.execQuery('CREATE TABLE command_responses_v0 ('
                                   'id SERIAL, '
                                   'command TEXT, '
                                   'response TEXT);')
    db_obj.closeConnection()
示例#6
0
    def do_work(self, user, functionName, args, bonusData):
        db = utilities_db.Praxis_DB_Connection(autoConnect=True)
        db.add_taskToQueue("standalone_discord", "user", str(time.time()), "name", user, "")

        # Sleep for a bit and then check to see if the task is done
        sleepy = True
        while sleepy:
            db_data = db.getTasksFromQueue("standalone_function")
            if db_data[5] == user:
                userName = db_data[6]
                sleepy = False
                db_data = db.deleteItems("task_queue_v0", "id", db_data[0])
            else:
                time.sleep(1)

        return userName
示例#7
0
    def __init__(self):
        super().__init__()
        self.twitchCredential: credentials.Twitch_Credential
        self.chat: twitch.Chat

        self.block_chat_url: bool = True
        self.whitelisted_users: list = ["thecuriousnerd"]
        # don't freak out, this is *merely* a regex for matching urls that will hit just about everything
        self._urlMatcher = re.compile(
            "(https?:(/{1,3}|[a-z0-9%])|[a-z0-9.-]+[.](com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))")

        # Default Twitch Chat limit is 20 per 30 seconds
        # If Mod or Op, Twitch Chat limit is 100 per 30 seconds
        self.cooldownModule: Cooldown_Module = Cooldown_Module()
        self.cooldownModule.setupCooldown("twitchChat", 20, 32)

        self.DB_Connection = utilities_db.Praxis_DB_Connection()
示例#8
0
    def get_Command_returnString(self, command, praxis_logger_obj:praxis_logging.praxis_logger = praxis_logging.praxis_logger()):
        try:
            db_obj = db_utility.Praxis_DB_Connection(autoConnect=True)
            returns = None
            #praxis_logger_obj.log("Getting Command ReturnString")

            query = "SELECT * FROM command_responses_v0 WHERE command = \'%s\';" % (command)
            #praxis_logger_obj.log(query)
            dbResults = db_obj.execQuery(query, praxis_logger_obj)
            #praxis_logger_obj.log("dbResults:")
            #praxis_logger_obj.log(str(dbResults))
            returns = dbResults[2]

            return returns

        except:
            print("UNABLE TO FIND RESPONSE")
            return None
    def do_work(self, user, functionName, args, bonusData):
        inputArgs = utility.list_to_string(args)
        newAudio = {}
        # Determine if inputArgs is either a url, a file, or a string
        if utility.contains_url(inputArgs):
            # inputArgs is a url
            newAudio["type"] = "url"
        elif utility.contains_pattern(
                inputArgs, ".*\.(mp3|pcm|wav|aiff|aac|ogg|wma|flac|alac)$"):
            # inputArgs is a file
            newAudio["type"] = "file"
        else:
            # inputArgs is a string
            newAudio["type"] = "tts"
        newAudio["text"] = inputArgs
        preppedAudio = dump(newAudio)

        db = utilities_db.Praxis_DB_Connection(autoConnect=True)
        db.add_taskToQueue("standalone_discord", "voice", str(time.time()),
                           "playNext", preppedAudio, "")
        return args
示例#10
0
 def do_work(self, user, functionName, args, bonusData):
     db = utilities_db.Praxis_DB_Connection(autoConnect=True)
     db.add_taskToQueue("standalone_discord", "voice", str(time.time()),
                        "resume", "", "")
     return args