Esempio n. 1
0
 async def unban(self, ctx, member_raw):
     member = await utils.convert_member(ctx, member_raw)
     if member.id in shared.banlist:
         shared.banlist.pop(member.id)
         utils.write_property('banlist', shared.banlist)
         await ctx.bot.add_reaction(ctx.message, shared.reaction_ok)
     else:
         await ctx.bot.add_reaction(ctx.message, shared.reaction_ko)
Esempio n. 2
0
    async def newgame(self, ctx, *, name: str = None):
        if not name:
            game = background.get_random_game()
        else:
            game = discord.Game(name=name.strip(), type=0)

        shared.enable_bg_game_rotation = True
        utils.write_property('enable_bg_game_rotation', True)
        await ctx.bot.change_presence(game=game)
Esempio n. 3
0
def change_avatar_if_needed():
    wait_time = 3600 * 8
    now = datetime.datetime.now(datetime.timezone.utc).timestamp()
    time = utils.read_property('avatar_change_time', None)

    if not time or (now - time) >= wait_time:
        utils.write_property('avatar_change_time', now)
        run_avatar_script()
        return wait_time + 1
    return wait_time - (now - time) + 1
Esempio n. 4
0
 async def auto(self, ctx, *, command='enable'):
     global moonrunes_auto_channel
     if command.lower() == 'enable':
         utils.write_property('moonrunes_auto_channel',
                              ctx.message.channel.id)
         moonrunes_auto_channel = ctx.message.channel.id
         await ctx.bot.add_reaction(ctx.message, shared.reaction_ok)
     elif command.lower() == 'disable':
         utils.write_property('moonrunes_auto_channel', None)
         moonrunes_auto_channel = None
         await ctx.bot.add_reaction(ctx.message, shared.reaction_ko)
Esempio n. 5
0
 async def on_ready(self):
     if utils.read_property('restarting', False):
         utils.write_property('restarting', False)
         channel = self.bot.get_channel(
             utils.read_property('restarting_channel', None))
         previous_time = datetime.datetime.fromtimestamp(
             utils.read_property('restarting_time'))
         seconds = (datetime.datetime.now() - previous_time).total_seconds()
         await self.bot.send_message(
             channel,
             f'Restarted successfully in {round(seconds)} seconds.')
Esempio n. 6
0
async def check_birthdays(bot):
    print(f'checking birthdays {datetime.datetime.utcnow()}')
    utils.write_property('last_birthday_check', datetime.datetime.utcnow().strftime('%Y-%m-%d'))

    session = database.new_session()
    users = session.query(database.User).filter(database.User.birthdate.isnot(None)).all()

    today = datetime.datetime.utcnow().strftime('%Y-%m-%d')
    for user in users:
        if user.birthdate[4:] == today[4:]:
            if user.discord_id not in shared.birthday_blacklist:
                if utils.is_birthdate_valid(user.birthdate):
                    await wish_birthday(bot, user)
Esempio n. 7
0
    async def setgame(self, ctx, type: str, *, name: str):
        trueType = {
            '0': 0,
            'playing': 0,
            '1': 1,
            'streaming': 1,
            '2': 2,
            'listening': 2,
            '3': 3,
            'watching': 3
        }.get(type.lower(), 0)
        game = discord.Game(name=name.strip(), type=trueType)

        shared.enable_bg_game_rotation = False
        utils.write_property('enable_bg_game_rotation', False)
        await ctx.bot.change_presence(game=game)
Esempio n. 8
0
 async def ban(self, ctx, member_raw, level: int = 0):
     member = await utils.convert_member(ctx, member_raw)
     shared.banlist[member.id] = level
     utils.write_property('banlist', shared.banlist)
     await ctx.bot.add_reaction(ctx.message, shared.reaction_ok)
Esempio n. 9
0
 async def setmalembed(self, ctx, *, template):
     template = template.strip(' `')
     utils.write_property('mal_embed_template', template)
     await ctx.bot.add_reaction(ctx.message, shared.reaction_ok)
Esempio n. 10
0
 async def ignorenickname(self, ctx, member_raw, value='true'):
     member = await utils.convert_member(ctx, member_raw)
     new_value = True if value.lower() in ['true', 'yes'] else False
     shared.name_restriction[member.id] = new_value
     utils.write_property('name_restriction', shared.name_restriction)
     await ctx.bot.add_reaction(ctx.message, shared.reaction_ok)