Пример #1
0
async def on_raw_reaction_add(payload):
    chan = payload.channel_id
    print(checksetting(conn, 'accountability', chan))
    if checksetting(conn, 'accountability', chan):
        if payload.emoji.name == "📌":
            msg = await bot.get_channel(payload.channel_id
                                        ).fetch_message(payload.message_id)
            await msg.pin()
        elif payload.message_id == bot.raid_id and bot.raidstatus == 1 and payload.emoji.name == "🗡️" and payload.member.bot == False:
            print("it's alive")
            looper.start()
            bot.raidstatus = 2
            channel = bot.get_channel(bot.account_id)
            raider = await channel.fetch_message(bot.raid_id)
            remain = "```RAID IS BEGINNING: " + str(bot.raidlen - bot.minutes +
                                                    1) + " MINUTES TO GO```"
            await channel.send("```RAID HAS STARTED!```")
            await raider.edit(content=remain)
        elif payload.message_id == bot.raid_id and bot.raidstatus == 1 and payload.emoji.name == "🛡️" and payload.member.bot == False:
            bot.raid_members.append(payload.member.id)
        elif payload.message_id == bot.raid_id and bot.raidstatus == 1 and payload.emoji.name == "💤" and payload.member.bot == False:
            print("it's alive")
            looper.start()
            bot.raidstatus = 2
            channel = bot.get_channel(bot.account_id)
            raider = await channel.fetch_message(bot.raid_id)
            remain = "```BREAK WAS STARTED: " + str(
                bot.raidlen - bot.minutes + 1) + " MINUTES REMAINING```"
            await raider.edit(content=remain)
        elif payload.message_id == bot.raid_id and bot.raidstatus == 1 and payload.emoji.name == "🛏️" and payload.member.bot == False:
            bot.raid_members.append(payload.member.id)
Пример #2
0
def getgroups(conn, id):
    groups = []
    if checksetting(conn, 'accountability', id):
        groups.append('accountability')
    if checksetting(conn, 'quest', id):
        groups.append('quest')
    if checksetting(conn, 'discussion', id):
        groups.append('discussion')
    if groups == []:
        groups.append('none')
    return groups
Пример #3
0
async def schedule(ctx, zone="UTC"):
    chan = ctx.message.channel.id
    if checksetting(conn, 'bot', chan):
        ev = convertlist(conn, geteventlist(conn), zone)
        message = ""
        today = getToday(zone)
        toddate = datetime.datetime.strptime(today, "%Y-%m-%d")
        stamp_list = [toddate + datetime.timedelta(days=x) for x in range(8)]
        date_list = []
        for i in stamp_list:
            date_list.append(i.date())
        print(date_list)
        for i in ev:
            print(i)
            if i[1] in date_list and i[2].hour > datetime.datetime.utcnow(
            ).time().hour or (
                    i[2].hour == datetime.datetime.utcnow().time().hour and
                    i[2].minute >= datetime.datetime.utcnow().time().minute):
                if i[3] != -1:
                    channel = bot.get_channel(i[3])
                else:
                    channel = discord.utils.get(ctx.guild.channels,
                                                name='common-room')
                line = "📖 " + str(i[1]) + " " + str(i[2]).rsplit(
                    sep=':',
                    maxsplit=1)[0] + " " + channel.mention + " " + i[4] + "\n"
                message += line
        if message == "":
            message = "```No events next week, sorry```"
        else:
            message = "```THIS IS THIS WEEK'S SCHEDULE```\n" + message
        await ctx.send(message)
    await ctx.message.delete()
Пример #4
0
async def on_message(message):
    hug = get(bot.emojis, name='BlobHug')
    chan = message.channel.id
    line = message.content
    print(getreaction(conn, line, chan))
    emo = getreaction(conn, line, chan)
    for i in emo:
        print(i)
        if i[:1] == ':':
            em = i[1:-1]
            emoji = get(bot.emojis, name=em)
            if emoji:
                await message.add_reaction(emoji)
        else:
            await message.add_reaction(i)
    if checksetting(conn, "discussion", chan):
        if ":BlobHug:" in line:
            bot.hug_counter += 1
            bot.hug_breaker = 0
        else:
            bot.hug_breaker = min(4, bot.hug_breaker + 1)
        if bot.hug_breaker > 3:
            bot.hug_counter = 0
        if bot.hug_counter == 5:
            response = str(hug)
            bot.hug_counter = 0
            await message.channel.send(response)

    await bot.process_commands(message)
Пример #5
0
async def on_raw_reaction_remove(payload):
    chan = payload.channel_id
    if checksetting(conn, 'accountability', chan):
        if payload.emoji.name == "📌":
            print("emoji_removed")
            msg = await bot.get_channel(payload.channel_id
                                        ).fetch_message(payload.message_id)
            await msg.unpin()
        elif payload.message_id == bot.raid_id and (
                bot.raidstatus == 2
                or bot.raidstatus == 1) and payload.emoji.name == "🛡️":
            raidmsg = await bot.get_channel(chan).fetch_message(bot.raid_id)
            reacs = raidmsg.reactions
            raiders = []
            for i in reacs:
                if i.emoji == "🛡️":
                    async for user in i.users():
                        raiders.append(user.id)
            print(raiders)
            for i in bot.raid_members:
                if i not in raiders:
                    bot.raid_members.remove(i)

            if bot.raid_members == []:
                print(bot.raid_members)
                looper.cancel()
Пример #6
0
async def local(ctx, date, time, zone):
    chan = ctx.message.channel.id
    if checksetting(conn, 'bot', chan):
        if time != "" and zone != "":
            if date == "today":
                date = utcToday()
            message = toLocal(date, time, zone)
        else:
            message = "Please use the format yyyy-mm-dd hh:mm Continent/City"
        await ctx.send(message)
    else:
        await ctx.message.delete()
Пример #7
0
async def breaks(ctx, times='5'):
    chan = ctx.message.channel.id
    if checksetting(conn, 'accountability', chan):
        if bot.on_raid == False:
            bot.raidlen = int(times)
            message = "```WAITING FOR BREAK OF " + times + " MINUTES TO START.....```"
            sent = await ctx.send(message)
            bot.account_id = ctx.message.channel.id
            await ctx.message.delete()
            bot.raid_id = sent.id
            await sent.pin()
            bot.on_raid = True
            bot.raidbreak = False
            await sent.add_reaction("🛏️")
            await sent.add_reaction("💤")
            bot.raidstatus = 1

        else:
            message = "TIMER IS ALREADY ON, SEE PINNED MESSAGES"
            await ctx.send(message)
            await ctx.message.delete()
Пример #8
0
async def ran(ctx, number, amount=1):
    chan = ctx.message.channel.id
    if checksetting(conn, 'bot', chan):
        await ctx.send(rannum(int(number), int(amount)))
Пример #9
0
async def flip(ctx):
    chan = ctx.message.channel.id
    if checksetting(conn, 'bot', chan):
        await ctx.send(coin())
Пример #10
0
async def quotenumber(ctx):
    chan = ctx.message.channel.id
    if checksetting(conn, 'bot', chan):
        await ctx.message.delete()
        message = quotenum(conn)
        await ctx.send(message)
Пример #11
0
async def de(ctx):
    chan = ctx.message.channel.id
    if checksetting(conn, 'bot', chan):
        await ctx.message.delete()
        message = removelast(conn)
        await ctx.send(message)
Пример #12
0
async def itl(ctx, language, line, trans=""):
    chan = ctx.message.channel.id
    if checksetting(conn, 'bot', chan):
        message = addquote(conn, language, line, trans)
        await ctx.send(message)
Пример #13
0
async def cookin(ctx):
    chan = ctx.message.channel.id
    if checksetting(conn, 'bot', chan):
        response = randomquote(conn)
        await ctx.send(response)
    await ctx.message.delete()