Ejemplo 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

    #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))
Ejemplo 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

    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))
Ejemplo n.º 3
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

    #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))
            isPeasant = True
        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

    global box_waiters

    if (random.randint(0, 249 + general.spam_activity(message.author.id)) == 1
            or message.author.id in box_waiters
        ) and not message.author.bot and message.guild == client.get_channel(
            int(config.bot_spam)).guild:
        if message.author.id in box_waiters:
            box_waiters.remove(message.author.id)
            print('Current box waiters: {}'.format(box_waiters))

        token = create_token(message.author.id)
        botspam_channel = client.get_channel(int(config.bot_spam))
        try:
            msg = await message.author.send(
                "Hey there! Thank you for playing on the Werewolves server! Follow this link to get an awesome reward!\nhttp://werewolves.1913-gaming.co.uk/unbox/"
                + token)
        except:
            await message.channel.send(
                'Ey, **{}**, I can\'t DM ya. Please make sure to enable this if you wish to participate on this server'
                .format(message.author.display_name))
            await botspam_channel.send(
                'I failed to send a lootbox to <@{}>. Too bad!'.format(
                    message.author.id))
        else:
            box.add_token(token, message.author.id, msg.id)
            await message.add_reaction('🎁')
            await botspam_channel.send('I sent a lootbox to <@{}>!'.format(
                message.author.id))

    await process_message(message,
                          process(message, isGameMaster, isAdmin, isPeasant),
                          isGameMaster, isAdmin, isPeasant)
Ejemplo n.º 4
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

    #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))
            isPeasant = True
        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

    global box_waiters

    if (random.randint(0, 249 + general.spam_activity(message.author.id)) == 1
            or message.author.id in box_waiters
        ) and not message.author.bot and message.guild == client.get_channel(
            int(config.bot_spam)).guild:
        if message.author.id in box_waiters:
            box_waiters.remove(message.author.id)
            print('Current box waiters: {}'.format(box_waiters))

        token = create_token(message.author.id)
        botspam_channel = client.get_channel(int(config.bot_spam))
        try:
            msg = await message.author.send(
                "Hey, so... this isn\'t completely finished yet - but you've won a lootbox!\nThis is only a testing stage, you won't actually get the prize you choose. Not yet.\nhttp://jamesbray.asuscomm.com/unbox/"
                + token)
        except:
            await message.channel.send(
                'Ey, **{}**, I can\'t DM ya. Please make sure to enable this if you wish to participate on this server'
                .format(message.author.display_name))
            await botspam_channel.send(
                'I failed to send a lootbox to <@{}>. Too bad!'.format(
                    message.author.id))
        else:
            box.add_token(token, message.author.id, msg.id)
            await message.add_reaction('🎁')
            await botspam_channel.send('I sent a lootbox to <@{}>!'.format(
                message.author.id))

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