Ejemplo n.º 1
0
    def read_data(year, month, day, hour):
        month = str(month).zfill(2)
        day = str(day).zfill(2)
        filename = "data/%d-%s-%s-%d.json.gz" % (year, month, day, hour)

        command = Command("parse_file", filename)
        command.execute()
Ejemplo n.º 2
0
    def download_data(year, month, day, hour):
        month = str(month).zfill(2)
        day = str(day).zfill(2)
        url = "http://data.githubarchive.org/%d-%s-%s-%d.json.gz" % (
            year, month, day, hour)

        command = Command("download_file", url)
        command.execute()
Ejemplo n.º 3
0
    def remote_command(self, message):
        if message[0] == self.cmd_token:
            GM.logger.info(f"Commands Received: [RemoteWebCall] -> {message}]")
            self.live_plugin_check()

            text = RemoteTextMessage(channel_id=GM.mumble.users.myself['channel_id'], session=GM.mumble.users.myself['session'], message=message, actor=GM.mumble.users.myself['session'])
            all_commands = [msg.strip() for msg in message.split(';')]

            # add to command history
            cmd_list = [GM.cmd_history.insert(cmd) for cmd in all_commands]

            if len(all_commands) > self.multi_cmd_limit:
                reg_print(
                    f"The multi-command limit was reached! The multi-command limit is {self.multi_cmd_limit} commands per line.")
                GM.logger.warning(
                    f"The multi-command limit was reached! The multi-command limit is {self.multi_cmd_limit} commands per line.")
                return

            # Iterate through all commands provided and generate commands.
            for i, item in enumerate(all_commands):
                # Generate command with parameters
                # new_text = copy.deepcopy(text)
                new_text = RemoteTextMessage(channel_id=GM.mumble.users.myself['channel_id'], session=GM.mumble.users.myself['session'], message=message, actor=GM.mumble.users.myself['session'])
                new_text.message = item
                new_command = None
                try:
                    new_command = Command(item[1:].split()[0], new_text)
                except IndexError:
                    continue

                if new_command.command in aliases.aliases:
                    alias_commands = [msg.strip() for msg in aliases.aliases[new_command.command].split('|')]
                    if len(alias_commands) > self.multi_cmd_limit:
                        reg_print(
                            f"The multi-command limit was reached! The multi-command limit is {self.multi_cmd_limit} commands per line.")
                        GM.logger.warning(
                            f"The multi-command limit was reached! The multi-command limit is {self.multi_cmd_limit} commands per line.")
                        return
                    for x, sub_item in enumerate(alias_commands):
                        # sub_text = copy.deepcopy(text)
                        sub_text = RemoteTextMessage(channel_id=GM.mumble.users.myself['channel_id'], session=GM.mumble.users.myself['session'], message=message, actor=GM.mumble.users.myself['session'])
                        if len(item[1:].split()) > 1:
                            sub_text.message = f"{sub_item} {item[1:].split(' ', 1)[1]}"
                        else:
                            sub_text.message = sub_item

                        sub_command = None
                        try:
                            sub_command = Command(sub_item[1:].split()[0], sub_text)
                        except IndexError:
                            continue

                        self.command_queue.insert(sub_command)
                else:
                    # Insert command into the command queue
                    self.command_queue.insert(new_command)

            # Process commands if the queue is not empty
            while not self.command_queue.is_empty():
                # Process commands in the queue
                self.process_command_queue(self.command_queue.pop())
                time.sleep(self.tick_rate)
Ejemplo n.º 4
0
    def message_received(self, text):
        message = text.message.strip()
        user = GM.mumble.users[text.actor]
        if "<img" in message:
            reg_print(f"Message Received: [{user['name']} -> Image Data]")
        elif "<a href=" in message:
            reg_print(f"Message Received: [{user['name']} -> Hyperlink Data]")
        else:
            reg_print(f"Message Received: [{user['name']} -> {message}]")

        if message[0] == self.cmd_token:
            GM.logger.info(f"Commands Received: [{user['name']} -> {message}]")
            self.live_plugin_check()

            # example input: !version ; !about ; !yt twice ; !p ; !status
            all_commands = [msg.strip() for msg in message.split(';')]
            # example output: ["!version", "!about", "!yt twice", "!p", "!status"]

            # add to command history
            cmd_list = [GM.cmd_history.insert(cmd) for cmd in all_commands]

            if len(all_commands) > self.multi_cmd_limit:
                reg_print(
                    f"The multi-command limit was reached! The multi-command limit is {self.multi_cmd_limit} commands per line.")
                GM.logger.warning(
                    f"The multi-command      d! The multi-command limit is {self.multi_cmd_limit} commands per line.")
                return

            # Iterate through all commands provided and generate commands.
            for i, item in enumerate(all_commands):
                # Generate command with parameters
                new_text = copy.deepcopy(text)
                new_text.message = item
                new_command = None
                try:
                    new_command = Command(item[1:].split()[0], new_text)
                except IndexError:
                    continue

                if new_command.command in aliases.aliases:
                    alias_commands = [msg.strip() for msg in aliases.aliases[new_command.command].split('|')]
                    if len(alias_commands) > self.multi_cmd_limit:
                        reg_print(
                            f"The multi-command limit was reached! The multi-command limit is {self.multi_cmd_limit} commands per line.")
                        GM.logger.warning(
                            f"The multi-command limit was reached! The multi-command limit is {self.multi_cmd_limit} commands per line.")
                        return
                    for x, sub_item in enumerate(alias_commands):
                        sub_text = copy.deepcopy(text)
                        if len(item[1:].split()) > 1:
                            sub_text.message = f"{sub_item} {item[1:].split(' ', 1)[1]}"
                        else:
                            sub_text.message = sub_item

                        sub_command = None
                        try:
                            sub_command = Command(sub_item[1:].split()[0], sub_text)
                        except IndexError:
                            continue

                        self.command_queue.insert(sub_command)
                else:
                    # Insert command into the command queue
                    self.command_queue.insert(new_command)

            # Process commands if the queue is not empty
            while not self.command_queue.is_empty():
                # Process commands in the queue
                self.process_command_queue(self.command_queue.pop())
                time.sleep(self.tick_rate)