예제 #1
0
        print(
            f"Got message \"{message.content}\" from user {message.author.name}#{message.author.discriminator} in the channel #{message.channel.name} ({str(message.channel.id)})"
        )

    if message.content.startswith("bundes"):
        params = message.content.split(" ")[1:]

        if len(params) > 0 and params[0] == "indian":
            if len(params) > 1 and params[1] == "start":
                core.start_process(indian_poker.program)
            else:
                if not core.is_process_running(indian_poker.program):
                    await message.channel.send(
                        "Process 'indian poker' hasn't been started")
                    await message.channel.send(
                        "pssst... *bundes indian start* <-- use this")


bundes_program = core.Program(puid="bundes", on_message=bundes_on_message)


@client.event
async def on_ready():
    await core.start_process(bundes_program)
    await core.start_process(message_transfer.program)
    core.init(client)
    print('We have logged in as {0.user}'.format(client))


client.run('ODE2MTg4NTA2MzcyMTc3OTgy.YD3Uxw.ppjwIuPVSfwLFDf16K8njY_Dh7I')
예제 #2
0
    return replace(game, players=[player])


async def process(pid, message, client):
    game = core.read_memory(pid, "game")
    if not game:
        game = Game("not started", [])
        core.write_memory(pid, "game", game)

    if message.content.startswith("bundes indian"):
        params = message.content.split(" ")[2:]
        if len(params) > 0 and params[0] == "start":
            if game.state != "not started":
                await message.channel.send(
                    "No, no, no. Only one game at a time. I'm sorry.")
                await message.channel.send(
                    "There's already another game going on or waiting for players. Try again next time."
                )
                return

            g1 = replace(game, state="waiting")
            g2 = register_player(g1, message.author)
            core.write_memory(PID, "game", g2)

            await message.channel.send("Let's freaking go!")
            await message.channel.send(
                "Type `bundes indian join` to join the game!")


program = core.Program(puid="indian", on_message=process)
예제 #3
0
            return 
        
        if not params[0].isdigit():
            await message.channel.send("You made an oopsie! Invalid channel ID format.")
            return
        
        channel_id = int(params[0])
        target_channel = client.get_channel(channel_id)
        
        if not target_channel:
            await message.channel.send("Sorry, I can't find the channel \:(")
            return
        
        if len(params) < 2 and len(message.attachments) == 0:
            await message.channel.send("Dude, I can't send an empty message!")
            return
        
        msg_to_send = " ".join(params[1:])
        msg_to_send = process_message(msg_to_send, target_channel, client)

        if len(message.attachments) > 0:
            msg_to_send = msg_to_send + "\n" + message.attachments[0].url
        
        await target_channel.send(msg_to_send)

program = core.Program(
    puid = "transfer",
    on_message = process
)

예제 #4
0
    message = reaction.message
    if user == opted_user and isinstance(message.channel, discord.DMChannel) \
    or message.channel == target_channel and user != client.user:
        corresponding_source_messages = [ m for m in messages if m.source_message == message ]
        corresponding_delivered_messages = [ m for m in messages if m.delivered_message == message ]

        for m in corresponding_source_messages:
            await m.delivered_message.remove_reaction(reaction, client.user)

        for m in corresponding_delivered_messages:
            await m.source_message.remove_reaction(reaction, client.user)

async def on_reaction_clear(pid, client, message, reactions):
    pass

async def on_reaction_clear_emoji(pid, client, reaction):
    pass

program = core.Program(
    puid = puid,
    on_process_start = on_process_start,
    on_process_end = on_process_end,
    on_message = on_message,
    on_message_edit = on_message_edit,
    on_message_delete = on_message_delete,
    on_reaction_add = on_reaction_add,
    on_reaction_remove = on_reaction_remove
    # on_reaction_clear = on_reaction_clear,
    # on_reaction_clear_emoji = on_reaction_clear_emoji
)
예제 #5
0
파일: bytecode.py 프로젝트: rjpower/guppy
 def __init__(self, bytecodes):
   self.p = core.Program()
   for b in bytecodes:
     self.p.add(b)
예제 #6
0
import core

program = core.Program(
    puid = "asdf"
    on_message = on_message
    on_reaction = on_reaction
)

async def on_message(pid, message, client):
    if core.in_memory(pid, "test1"):
        test1 = core.read_memory(pid, "test1")

    core.write_global_memory()
    core.load_saved()
        
    pass