def process(self):
     while True:
         cur_actor = self.actors.pop()
         cur_actor.gain_energy()
         if cur_actor.energy >= Scheduler.ACTION_REQ_ENERGY:
             if cur_actor.is_player and cur_actor.needs_input:
                 return
             else:
                 cmd = cur_actor.take_action()
                 process_command(cur_actor, cmd)
     self.__clock += 0.1
Esempio n. 2
0
    def on_pubmsg(self, source, target, message):
        arguments = message.split(' ')
        if (len(arguments) > 2):
            if (arguments[0].lower() == self.nickname.lower() + ':'):
                process_command(self, source, target, arguments[1], arguments[2:])
            if (arguments[0][0] == '!'):
                process_command(self, source, target, arguments[1][1:], arguments[2:])

        url = has_url(message)
        if url:
            data = process_url(source, url)
            if (data):
                self.message(source, data)
def main(event, context):
    slack_token = os.environ.get("SLACK_TOKEN", "")
    slack_data = parse_input(event["body"])
    command_types = ["get", "create", "update", "delete"]
    command_subtypes = [
        "app", "sandbox", "build", "policy", "user", "apps", "sandboxes",
        "builds", "policies", "users"
    ]

    # Check Slack token matches
    if slack_token == "" or slack_token != slack_data.get("token", ""):
        return
    else:
        split_text = slack_data["text"].split()
        if len(split_text) >= 2:
            command_type = split_text.pop(0)
            command_subtype = split_text.pop(0)
            if command_type in command_types and command_subtype in command_subtypes:
                command_output = commands.process_command(
                    command_type, command_subtype, split_text)
                requests.post(slack_data["response_url"],
                              data=json.dumps(command_output))
                return command_output
            else:
                error = tools.generate_error("Unknown command in `/veracode " +
                                             slack_data["text"] + "`")
                requests.post(slack_data["response_url"],
                              data=json.dumps(error))
                return error
        else:
            error = tools.generate_error(
                "Missing command in `" +
                " ".join(["/veracode", slack_data["text"]]) + "`")
            requests.post(slack_data["response_url"], data=json.dumps(error))
            return error
Esempio n. 4
0
def process_chat(user, message):
    if len(message)>0:
        prefix, _ , rest = message.partition(' ')
        if prefix[0]=='!':
            command = prefix[1:].strip()
            msg = rest.strip()
            result = process_command(user, msg, command)
            if result!=None:
                chat(s, result)
Esempio n. 5
0
def schedule(system):
    # priority events
    if commands.process_command(system):
        return True
    # scheduled Events
    ## get current_ time/date
    today = datetime.datetime.now()
    if schedule_purchase_reports(system, today, weeks=12):
        return True
    if schedule_input_purchase(system, today, days=30):
        return True
    stock.price_system()
Esempio n. 6
0
async def on_message(message):
    if message.content[0:3].lower() != "svr":
        return

    command = parse_msg(message.content.lower(), message.clean_content)

    if message.author.id == int(os.getenv('ADMIN')):
        if command[0] == "shut":
            cfg.save_p_users()
            await message.channel.send("Shutting down :(")
            await client.close()
            return
        #await message.channel.send(admin_command(command, cfg))
        await message.channel.send(process_command(command, cfg, 0, True))

    #elif cfg.check_p_user(message.author.id):
    #    await message.channel.send(p_user_command(command))#
    #
    #else:
    #    await message.channel.send(user_command(command))
    else:
        await message.channel.send(
            process_command(command, cfg, str(message.author.id)))
Esempio n. 7
0
    async def on_message(message):
        if message.author == discord_client.user:
            return
        global config_prefix

        content = message.content.lstrip()

        prefixes = (
            '<@%s>' % discord_client.user.id,
            '<@!%s>' % discord_client.user.id)

        if config_prefix is not None:
            if isinstance(config_prefix, (list, tuple)):
                prefixes += tuple(config_prefix)
            else:
                prefixes += (config_prefix.lower(),)

        if content.lower().startswith(prefixes): # Checking all messages that start with the prefix.
            prefix = [prefix for prefix in prefixes if content.lower().startswith(prefix)][0]
            command_content = content[len(prefix):].lstrip()
            response = discord_postprocess(
                process_command(
                    DiscordAccountId(str(message.author.id)),
                    command_content,
                    server,
                    prefixes[0] + ' '))

            chunks = split_into_chunks(response.encode('utf-8'), 1024)
            try:
                embed = discord.Embed(color=int(config["colour"], base=16))
            except Exception as e:
                print_bad("Embed Colour")
                embed = discord.Embed()
                pass
            title = command_content.split()[0] if len(command_content.split()) > 0 else 'Empty Message'
            for i, chunk in enumerate(chunks):
                title = "(cont'd)" if i > 0 else title
                embed.add_field(name=title, value=chunk.decode('utf-8'), inline=False)

            embed.set_thumbnail(url=message.author.avatar_url)
            embed.set_footer(text="This was sent in response to %s's message; you can safely disregard it if that's not you." % message.author.name)

            await message.channel.send(embed=embed)
Esempio n. 8
0
    async def on_message(message):
        if message.author == discord_client.user:
            return

        content = message.content.lstrip()
        prefixes = (
            '<@%s>' % discord_client.user.id,
            '<@!%s>' % discord_client.user.id)

        if content.startswith(prefixes): # Checking all messages that start with the prefix.
            response = discord_postprocess(
                process_command(
                    DiscordAccountId(str(message.author.id)),
                    content[content.index('>') + 1:].lstrip(),
                    server,
                    prefixes[0] + ' '))

            chunks = split_into_chunks(response.encode('utf-8'), 1024)
            embed = discord.Embed(color=0x3b4dff)
            for i, chunk in enumerate(chunks):
                title = "(cont'd)" if i > 0 else 'Response to %s' % message.author.name
                embed.add_field(name=title, value=chunk.decode('utf-8'), inline=False)

            await message.channel.send(embed=embed)
Esempio n. 9
0
 def on_privmsg(self, source, target, message):
     arguments = message.split(' ')
     if (len(arguments) > 1):
         process_command(self, source, target, arguments[0], arguments[1:])
Esempio n. 10
0
def process_comment(comment, server):
    """Processes a comment with the proper prefix."""
    author = RedditAccountId(comment.author.name)
    comment.reply(process_command(author, comment.body[len(prefix):], server))
Esempio n. 11
0
def process_message(message, server):
    """Processes a message sent to the bot."""
    reply(message, process_command(RedditAccountId(message.author.name), message.body, server))
Esempio n. 12
0
options = commands.defaults(height, width)

# configure camera for 720p @ 60 FPS
cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
cap.set(cv2.CAP_PROP_FPS, 60)

fake = pyfakewebcam.FakeWebcam('/dev/video20', width, height)

while True:
    try:
        if select.select([
                sys.stdin,
        ], [], [], 0.0)[0]:
            options = commands.process_command(sys.stdin.readline(), options)
            if options['reload']:
                importlib.reload(process_frame)
                importlib.reload(commands)
                print('reloaded modules')
                options['reload'] = False
    except Exception as e:
        print(e)

    _, frame = cap.read()

    try:
        frame = process_frame.get_frame(frame, options)
    except Exception as e:
        print(e)
Esempio n. 13
0
import audio_manager, commands, sys

print('creating playlist . . .')
# audio_manager.add_playlist('https://www.youtube.com/playlist?list=PLTfTRP_g2I3SiIEej6tWzvDc0uWiz_icx') # energetic classical
# audio_manager.add_playlist('https://www.youtube.com/playlist?list=PLTfTRP_g2I3QQYS-WT_OtjxowNdvJlCFZ') # classical favs
audio_manager.add_playlist(
    'https://www.youtube.com/playlist?list=PLTfTRP_g2I3Rlo_MG2nPsTAHdQO40PwsA'
)  # classical lax
# audio_manager.add_playlist('https://www.youtube.com/watch?v=YD9QvvhI6Sk&list=PL7CFEF478E3980B62') # mario galaxy
# audio_manager.add_video('https://www.youtube.com/watch?v=XYWu50NYLUI') # smash 4
audio_manager.shuffle()
audio_manager.start_playlist(repeat=True)

while audio_manager.is_playing:
    commands.process_command(input())