Exemple #1
0
async def on_ready():
    """
    When bot is ready and online it prints that its online
    :return:
    """
    bot.timer_manager = timers.TimerManager(bot)
    logger.debug("Bot is ready!")
Exemple #2
0
async def on_ready():
    """
    When bot is ready and online it prints that its online
    :return:
    """
    bot.timer_manager = timers.TimerManager(bot)
    logger.debug("===== Bot is ready! =====")
    logger.debug(f"===== Logged in as {bot.user} =====")
Exemple #3
0
    def __init__(self, bot):
        self.bot = bot
        self.bot.timer_manager = timers.TimerManager(self.bot)

        # Check if first time being run
        if not SETTINGS_FILE.is_file():
            if not RESOURCES_FOLDER.is_dir():
                RESOURCES_FOLDER.mkdir()
            SETTINGS_FILE.write_text(json.dumps({}, indent=4), encoding='utf8')
Exemple #4
0
            str(new_date.day) + "/" + str(new_date.month) + "/" +
            str(new_date.year))
        index += 1

    data = {'events': events, 'dates': events_date}
    dataFrame = pd.DataFrame(data=data)

    return dataFrame


# ////////////////////////// < GLOBAL FUNCTION > /////////////////////////////////////////

intents = discord.Intents.all()
bot = commands.Bot(command_prefix='$', intents=intents)
client = discord.Client()
bot.timer_manager = timers.TimerManager(bot)

# ////////////////////////// < EVENT FUNCTION > /////////////////////////////////////////


@bot.event
async def on_ready():
    print("Bot Ready !")
    config = configparser.ConfigParser()
    config.read('config.ini')

    if config['ANNONCES']['GENERALE'] is not None and config['ANNONCES'][
            'HOURS'] is not None:
        desc = config['ANNONCES']['GENERALE']
        hours = int(config['ANNONCES']['HOURS'])
        # client.loop.create_task(annonce_quotidienne(hours, desc))
Exemple #5
0
    def __init__(self):
        intents = discord.Intents.all()
        intents.members = True
        self.bot = ASharkyBot(command_prefix='$', intents=intents)
        self.client = discord.Client()
        self.bot.timer_manager = timers.TimerManager(self.bot)
        self.abyss_annonce = False

        # ////////////////////////// < EVENT FUNCTION > /////////////////////////////////////////

        @self.bot.event
        async def on_ready():
            await self.bot.change_presence(activity=discord.Game('Tide of War')
                                           )
            self.bot.loop.create_task(abys_function())
            self.bot.loop.create_task(annonce_quotidienne())
            print("Bot Ready !")

        @self.bot.event
        async def on_member_join(member):
            desc = f"Un merveilleux pirates du nom de {member.mention}, nous rejoinds \n" \
                   f"souhaiter lui la bienvenue avec un bon verre de rhum  \n\n" \
                   f"N'oubliez pas les règles suivantes : \n" \
                   f"1) Mettez un shield 24h avant d'aller dormir \n" \
                   f"2) Vérifiez les Check in tout les jours \n" \
                   f"3) Ne pas attaquez les batiments sous aucun prétexte sous peine d'exclusion \n"

            mbed = discord.Embed(colour=(discord.Colour.dark_blue()),
                                 title=f"Bienvenue chez LSB",
                                 description=desc)

            mbed.set_image(
                url=
                "https://tel.img.pmdstatic.net/fit/http.3A.2F.2Fprd2-bone-image.2Es3-website-eu-west-1.2Eamazonaws.2Ecom.2FTEL.2F2019.2F09.2F20.2F4ef6192a-9f74-4f2b-a4ac-96b8cc01bc72.2Ejpeg/619x450/quality/65/pirates-des-caraibes-1-dans-la-saga-disney-tous-les-ingredients-d-un-film-de-pirates-sont-reunis-ici-le-rhum.jpg"
            )
            await self.bot.welcom_channel.send(embed=mbed)
            await member.send(embed=mbed)

        @self.bot.event
        async def on_member_remove(member):
            mbed = discord.Embed(
                colour=(discord.Colour.dark_blue()),
                title=f"LSB vous dit Aurevoir !",
                description=
                f"Nous vous remercions d'avoir participé dans notre alliance {member.mention} \n"
            )
            mbed.set_image(
                url=
                "https://static1.terrafemina.com/articles/9/28/00/69/@/316508-anne-dieuleveut-622x0-2.jpg"
            )
            await self.bot.goodbye_channel.send(embed=mbed)

        @self.bot.event
        async def on_reminder(*text):
            textes = ""
            for t in text:
                textes += t

            desc = "@eveyone \n\n"
            desc += "Hello tout le monde je suis SharkyBot, je vous envoie ce message pour rappeller ceci : \n\n"
            desc += textes

            mbed = discord.Embed(colour=(discord.Colour.dark_blue()),
                                 title=f"Sharkybot Rappel ",
                                 description=desc)
            await self.bot.annonce_channel.send(embed=mbed)

        # ////////////////////////// < COMMAND FUNCTION > /////////////////////////////////////////

        @self.bot.command()
        async def au_goulag_timer(ctx, username=None, _time=None):
            await ctx.channel.purge(limit=1)

            if self.bot.is_admin(ctx):
                if _time is not None and username is not None:
                    try:
                        time = int(_time)
                        self.bot.loop.create_task(
                            au_goulag(ctx, username, True))
                        await asyncio.sleep(time)
                        self.bot.loop.create_task(
                            remove_goulag(ctx, username, True))
                    except ValueError:
                        await ctx.channel.send(
                            "La commande n'est pas correcte utiliser $au_goulag_timer username seconds "
                        )
                    finally:
                        pass
                else:
                    await ctx.channel.send(
                        "La commande n'est pas correcte utiliser $au_goulag_timer username seconds "
                    )
            else:
                await ctx.channel.send(
                    f"SharkyBot dis que {ctx.author.mention} n'est pas authorisé a faire sa !"
                )

        @self.bot.command()
        async def au_goulag(ctx, username=None, Remove=None):

            if Remove is None:
                await ctx.channel.purge(limit=1)

            if self.bot.is_admin(ctx):
                if username is not None:
                    member = self.bot.get_member(username)
                    role = self.bot.get_role("GOULAG")
                    role_lsb = self.bot.get_role("lsb menber")
                    id = self.bot.get_channel_id("au-goulag")
                    channel = self.bot.get_channel(id)
                    await member.add_roles(role)
                    await member.remove_roles(role_lsb)
                    await channel.send(
                        f"L'utilisateur {member.mention} à été envoyé au goulag @everyone "
                    )
            else:
                await ctx.channel.send(
                    f"SharkyBot dis que {ctx.author.mention} n'est pas authorisé à faire sa !"
                )

        @self.bot.command()
        async def remove_goulag(ctx, username=None, Remove=None):

            if Remove is None:
                await ctx.channel.purge(limit=1)

            if self.bot.is_admin(ctx):
                if username is not None:
                    member = self.bot.get_member(username)
                    role = self.bot.get_role("GOULAG")
                    role_lsb = self.bot.get_role("lsb menber")
                    id = self.bot.get_channel_id("au-goulag")
                    channel = self.bot.get_channel(id)
                    await member.remove_roles(role)
                    await member.add_roles(role_lsb)
                    await channel.send(
                        f"L'utilisateur {member.mention} à été sortie du goulag @everyone "
                    )
            else:
                await ctx.channel.send(
                    f"SharkyBot dis que {ctx.author.mention} n'est pas authorisé a faire sa !"
                )

        @self.bot.command()
        async def hello(ctx):
            await ctx.channel.purge(limit=1)
            await ctx.channel.send("Bonjour " + str(ctx.author.mention) + " !")

        @self.bot.command()
        async def get_members(ctx):
            await ctx.channel.purge(limit=1)
            members = ""
            if self.bot.is_admin(ctx):
                for guild in self.bot.guilds:
                    for m in guild.members:
                        members += m.name + " - "
                await ctx.channel.send("members : " + members)
            else:
                await ctx.channel.send(
                    f"SharkyBot dis que {ctx.author.mention} n'est pas authorisé a faire sa !"
                )

        @self.bot.command()
        async def ping(ctx, arg=None):
            await ctx.channel.purge(limit=1)

            if self.bot.is_admin(ctx):
                if arg == "pong":
                    await ctx.channel.send("Vous avez déjà Ping vous-même !")
                else:
                    await ctx.channel.send(str(ctx.author.mention) + " Pong !")
            else:
                await ctx.channel.send(
                    f"SharkyBot dis que {ctx.author.mention} n'est pas authorisé a faire sa !"
                )

        # ////////////////////////// < CLEAR FUNCTION > /////////////////////////////////////////

        @self.bot.command()
        async def clear_limit(ctx, arg):
            await ctx.channel.purge(limit=1)
            if self.bot.is_admin(ctx):
                try:
                    nb = int(arg)
                    await ctx.channel.purge(limit=nb)
                except ValueError:
                    await ctx.channel.send(
                        'commande impossible veuillez entrer un numéro ! => $clear_limit (number)'
                    )
                finally:
                    pass
            else:
                await ctx.channel.send(
                    f"SharkyBot dis que {ctx.author.mention} n'est pas authorisé a faire sa !"
                )

        @self.bot.command()
        async def clear_channel(ctx, arg=None):
            await ctx.channel.purge(limit=1)

            if self.bot.is_admin(ctx):
                if arg is None:
                    ctx.channel.send(
                        'Veuillez entrer un channel ! Sinon je ne peut pas le nettoyer :)'
                    )
                else:
                    try:
                        id = self.bot.get_channel_id(arg)
                        channel = self.bot.get_channel(id)
                        if type(channel) is not None:
                            await channel.purge()
                        else:
                            ctx.channel.send(
                                'Channel introuvable veuillez entrer le bon channel !'
                            )
                    except ValueError:
                        ctx.channel.send(
                            'Channel introuvable veuillez entrer le bon channel !'
                        )
                    finally:
                        pass
            else:
                await ctx.channel.send(
                    f"SharkyBot dis que {ctx.author.mention} n'est pas authorisé a faire sa !"
                )

        @self.bot.command()
        async def clear_all(ctx, channel=None):
            await self.bot.clear_all(ctx=ctx, channel=channel)

        # ////////////////////////// < TIMER FUNCTION > /////////////////////////////////////////

        @self.bot.command(name="remind")
        async def remind(ctx, time, *, text):
            await ctx.channel.purge(limit=1)

            if self.bot.is_admin(ctx):
                """Remind to do something on a date.
                The date must be in ``Y/M/D`` format."""
                date = datetime(*map(int, time.split("/")))
                self.bot.timer_manager.create_timer("reminder",
                                                    date,
                                                    args=text)
            else:
                await ctx.channel.send(
                    f"SharkyBot dis que {ctx.author.mention} n'est pas authorisé a faire sa !"
                )

        @self.bot.command()
        async def new_annonce(ctx, timers, *_desc):
            await ctx.channel.purge(limit=1)

            if self.bot.is_admin(ctx):
                try:
                    desc = ""
                    for d in _desc:
                        desc += d

                    print(str(timers) + " " + str(desc))
                    self.bot.loop.create_task(
                        self.bot.global_annonce(int(timers), str(desc)))
                except ValueError:
                    await ctx.channel.send(
                        "Commande non acceptée timer n'est pas un chiffre en secondes ! => $new_annnonce 120 annonce"
                    )
            else:
                await ctx.channel.send(
                    f"SharkyBot dis que {ctx.author.mention} n'est pas authorisé a faire sa !"
                )

        # ////////////////////////// < EVENTS FUNCTION > /////////////////////////////////////////

        async def abys_function():
            self.abyss_annonce = False
            while True:
                if self.bot.is_abyss() and self.abyss_annonce is False:
                    desc = "L'antre des abysses est réinitialisée aujourd'hui ! Bon jeu et Bonne chances dans les tréfonds :D"
                    self.bot.loop.create_task(on_reminder(desc))
                    self.abyss_annonce = True
                else:
                    self.abyss_annonce = False
                    # Waitting 24H
                    await asyncio.sleep(86400)

        async def annonce_quotidienne():
            self.bot.annonce_quotidienne = False
            next_day = datetime.now().day

            while True:
                hours = datetime.now().hour
                day = datetime.now().day

                if day == next_day and hours == self.bot.hours_annonce_quotidienne and self.bot.annonce_quotidienne is False:
                    print("Il est 16H00 je dois faire une annonce !")

                    desc = "@eveyone \n\n"
                    desc += "Hello tout le monde je suis SharkyBot,\n Je vous rappelle ceci : \n\n"
                    desc += self.bot.desc_annonce_quotidienne

                    mbed = discord.Embed(colour=(discord.Colour.dark_blue()),
                                         title=f"Sharkybot Rappel ",
                                         description=desc)

                    await self.bot.clear_all(channel=self.bot.annonce_channel)
                    self.bot.annonce_channel.send(embed=mbed)
                    self.bot.annonce_quotidienne = True
                    await asyncio.sleep(300)

                elif day != next_day:
                    print("Le jour quotidien a changé !")
                    next_day = day
                    self.bot.annonce_quotidienne = False
 def __init__(self, bot):
     self.emoji = ":money_with_wings:"
     self.bot = bot
     self.timer_manager = timers.TimerManager(bot)
 def __init__(self, bot):
     self.emoji = ":tools:"
     self.bot = bot
     self.timer_manager = timers.TimerManager(bot)
     with open("data/config.json", "r") as f:
         self.config = json.load(f)
Exemple #8
0
import sqlite3
from operator import itemgetter
from pytz import timezone
import psycopg2

timescales = [
    'sec', 'second', 'min', 'minute', 'hour', 'day', 'week', 'month', 'year'
]  # right now only supports up to week
unicode_block = [
    '🇦', '🇧', '🇨', '🇩', '🇪', '🇫', '🇬', '🇭', '🇮',
    '🇯', '🇰', '🇱', '🇲', '🇳', '🇴', '🇵', '🇶', '🇷',
    '🇸', '🇹', '🇺', '🇻', '🇼', '🇽', '🇾', '🇿'
]

client = commands.Bot(command_prefix='!')
client.timer_manager = timers.TimerManager(client)
client.remove_command("help")

#On Ready Event------------------------------------------


@client.event
async def on_ready():
    await client.change_presence(status=discord.Status.online,
                                 activity=discord.Game(" !help"))
    print('Logged in as: {0.user}'.format(client))


#General Error Handling----------------------------------

Exemple #9
0
 def __init__(self, bot):
     self.bot = bot
     self.bot.timer_manager = timers.TimerManager(self.bot)