Exemplo n.º 1
0
async def on_message(message):
    # we do not want the bot to reply to itself
    if message.author == client.user:
        #stats.increment_stat("bot_messages_sent", 1)
        return
    #stats.increment_stat("messages_sent", 1)
    #stats.increment_user_stat(message.author.id, "messages_sent", 1)

    # Add trash messages
    db.add_trash_message(message.id,message.channel.id)

    #check role of sender
    isGameMaster = False
    isAdmin = False
    isPeasant = False
    if message.guild == client.get_channel(int(config.game_log)).guild:
        try:
            role_table = [y.id for y in message.guild.get_member(message.author.id).roles]
        except Exception:
            print('Unable to acquire role_table from {}'.format(message.author.display_name))
        else:
            if game_master in role_table:
                isGameMaster = True
            if administrator in role_table:
                isAdmin = True
            if peasant in role_table and message.author.bot == True:
                isPeasant = True

    await process_message(message,process(message,isGameMaster,isAdmin,isPeasant))
Exemplo n.º 2
0
async def on_message_edit(before, after):
    if before.author == client.user: # We don't want to respond to our own edits
        return
    if before.content == after.content: # Ensure it wasn't just a pin
        return
    #stats.increment_stat("messages_edited", 1)
    #stats.increment_user_stat(before.author.id, "messages_edited", 1)

    if before.id != after.id:
        db.add_trash_message(after.id,after.channel.id)

    #check role of sender
    isGameMaster = False
    isAdmin = False
    isPeasant = False
    try:
        if after.guild == client.get_channel(int(config.game_log)).guild:
            role_table = [y.id for y in after.guild.get_member(after.author.id).roles]

            if game_master in role_table:
                isGameMaster = True
            if administrator in role_table:
                isAdmin = True
            if peasant in role_table and after.author.bot == True:
                isPeasant = True
    except Exception:
        pass

    await process_message(after,process(after,isGameMaster,isAdmin,isPeasant))
Exemplo n.º 3
0
async def on_message_edit(before, after):
    if before.author == client.user:  # We don't want to respond to our own edits
        return
    if before.content == after.content:  # Ensure it wasn't just a pin
        return

    if before.id != after.id:
        db.add_trash_message(after.id, after.channel.id)

    #check role of sender
    isGameMaster = False
    isAdmin = False
    isPeasant = False
    try:
        if after.guild == client.get_channel(int(config.game_log)).guild:
            role_table = [
                y.id for y in after.guild.get_member(after.author.id).roles
            ]

            if game_master in role_table:
                isGameMaster = True
            if administrator in role_table:
                isAdmin = True
            if peasant in role_table and after.author.bot == True:
                isPeasant = True
    except Exception:
        # We want the Ghost Bot to listen to the webhooks, who send data from the website.
        isPeasant = True

    await process_message(after,
                          process(after, isGameMaster, isAdmin, isPeasant),
                          isGameMaster, isAdmin, isPeasant)