Example #1
0
    def __init__(self, alias, name, link):

        self.alias = alias
        self.name = name
        self.link = link
        self.time = time.time()

        Querry(f"DELETE FROM `wh` WHERE `alias`='{self.alias}'")
        Querry(
            f"INSERT INTO `wh` (`alias`, `name`, `link`, `lastuse`) VALUES ('{self.alias}','{self.name}','{self.link}',{self.time})"
        )
Example #2
0
    def __init__(self, idd, name, grade, poste, money=0, CP=100, location=782727850624548864, service_time=0):

        self.name = name
        self.idd = idd
        self.grade = grade
        self.poste = str(poste)
        self.hierarchie = hierarchieDB[self.grade]
        self.money = money
        self.CP = CP
        self.location = location
        self.service_time = service_time

        Querry(f"DELETE FROM `profil` WHERE `idd`={self.idd}")
        Querry(f"INSERT INTO `profil`(`idd`, `name`, `grade`, `hierarchie`, `poste`, `money`, `CP`, `location`, `service_time`)\
        VALUES ({self.idd},'{self.name}',{self.grade},{self.hierarchie},'{self.poste}',{self.money},{self.CP},{self.location},{self.service_time})")
Example #3
0
    async def listt(self):

        datas = Querry("SELECT alias FROM wh ORDER BY lastuse DESC")
        content = ""
        maxpages = math.ceil(len(datas) / 25)

        try:
            page = int(self.message.content.split(" ")[2])
            if page > maxpages:
                page = maxpages
        except:
            page = 1

        for i in range(25 * (page - 1), 25 * (page)):
            try:
                idwh = datas[i][0]
            except:
                break
            wh = ExistWh(idwh)
            content += f"\n **-** {wh.alias} > {wh.name} **|** Expiration `{wh.expiration_str}`"

        content += f"\n\n Page `{page}`/`{maxpages}` | Do !wh list <p>"
        embed = discord.Embed(title="Liste des alias de WebHook (alias > nom)",
                              description=f"{content}",
                              color=0x00ffe1)
        embed.set_footer(text=FOOTER)
        await self.message.channel.send(embed=embed)
Example #4
0
    def __init__(self, id_owner, expiration):

        self.id_owner = id_owner
        self.expiration = expiration

        Querry(f"INSERT INTO `bip`(`id_owner`, `expiration`)\
        VALUES ({self.id_owner},{self.expiration})")
Example #5
0
 def update_syno(self):
     service = Querry("SELECT * FROM service")
     for data in service:
         i, uid, name, starttime, cta = data
         player = ExistProfil(uid)
         if not cta: self.syno[player.hierarchie - 1] += 1
         if cta: self.syno[5] += 1
     return self
Example #6
0
 def update_cp(self, value):
     try:
         assert self.CP + value > 0
     except:
         self.CP, value = 0, 0
     uptade = Querry(
         f"UPDATE `profil` SET `CP`={self.CP+value} WHERE idd={self.idd}")
     return value
Example #7
0
    def __init__(self, id_owner, expiration, frequency):

        self.id_owner = id_owner
        self.expiration = expiration
        self.frequency = frequency
        
        Querry(f"INSERT INTO `tph`(`id_owner`, `expiration`, `Frequency`)\
        VALUES ({self.id_owner},{self.expiration},'{self.frequency}')")
Example #8
0
def delete_expired_tph():
    try:
        whs = Querry("SELECT * FROM tph")
        for wh in whs:
            tph = ExistTph(wh[1])
            if tph.has_expired():
                tph.drop()
    except: pass
Example #9
0
    def __init__(self, id_owner, expiration, channel):

        self.id_owner = id_owner
        self.expiration = expiration
        self.channel = channel

        Querry(f"INSERT INTO `House`(`owner_id`, `last_message`, `chan_id`)\
        VALUES ({self.id_owner},{self.expiration},{self.channel})")
Example #10
0
def delete_expired_wh():
    try:
        whs = Querry("SELECT alias FROM wh")
        for wh in whs:
            whh = ExistWh(wh[0])
            if whh.has_expired():
                whh.delete()
    except:
        pass
Example #11
0
def delete_expired_house():
    supress = []
    try:
        houses = Querry("SELECT * FROM House")
        for house in houses:
            house = ExistHouse(house[1])
            if house.has_expired():
                cid = house.drop()
                supress.append(cid)
    except:
        pass
    finally:
        return supress
Example #12
0
async def expired_pager_manager():
    try:
        datas = Querry("SELECT * FROM bip")
        for data in datas:
            bip = ExistBip(wh[1])
            if bip.has_expired() and not bip.has_low_battery:
                bip.set_lowbattery()
                bip.set_time_before_down()

            elif bip.has_expired and bip.has_low_battery:
                ExistProfil(bip.id_owner).end_service()
                bip.drop()

    except:
        pass
Example #13
0
    async def run(self):
        if not self.has_permission: return await self.not_permission()

        self.player = ExistProfil(self.message.author.id)
        datas = Querry("SELECT * FROM service")
        cislist = " "
        ctalist = " "
        for data in datas:
            i, uid, name, starttime, cta = data
            member = self.message.guild.get_member(uid)
            name = member.display_name
            duringtime = time.time() - starttime
            minutes = int(duringtime / 60)
            hours = int(minutes / 60)
            minutes -= hours * 60
            if cta:
                ctalist += f"• {name}  en garde depuis `{hours} heure(s) et {minutes} minute(s)`\n"
            else:
                cislist += f"• {name} **|** {member.id} \n Durée de service : `{hours} heure(s) et {minutes} minute(s)`\n\n"

        embedcta = discord.Embed(description=f"{ctalist}", color=0xb3ff00)
        embedcta.set_author(
            name="Tableau de garde CTA 34",
            icon_url=
            "https://www.pompiercenter.com/images/sdis/logos/34logo_Logo-Herault-sapeurs-pompiers-rvb-coul%20-%20Copie.jpg"
        )
        embedcta.set_footer(text=FOOTER)

        embedcis = discord.Embed(description=f"{cislist}", color=0xff0000)
        embedcis.set_author(
            name="Tableau de garde CSP Sète",
            icon_url=
            "https://www.radioone.fr/upload/news/main/5ec7c8f918faa4.67062370.JPG?=1617323441"
        )
        embedcis.set_footer(text=FOOTER)

        await self.message.channel.send(embed=embedcta)
        await self.message.channel.send(embed=embedcis)
Example #14
0
 def refresh(self):
     self.expiration = __import__("time").time() + 60*60*1.5
     Querry(f"UPDATE tph SET `expiration`={self.expiration} WHERE `id_owner`={self.id_owner}")
Example #15
0
 def start_service(self, cta):
     astreinte = Querry(
         f"INSERT INTO `service`(`idd`, `name`, `time`, `cta`)\
     VALUES ({self.idd},'{self.name}',{__import__('time').time()},{cta})")
Example #16
0
 def drop(self):
     Querry(f"DELETE from tph WHERE `id_owner`={self.id_owner}")
     alias = "tph-" +str(self.id_owner)
     Querry(f"DELETE from wh WHERE alias='{alias}'")
Example #17
0
 def set_frequency(self, frequency):
     self.frequency = frequency
     Querry(f"UPDATE tph SET `frequency`='{self.frequency}' WHERE `id_owner`={self.id_owner}")
Example #18
0
 def end_service(self):
     time = Querry(f"SELECT `time` FROM service WHERE idd={self.idd}")
     end = Querry(f"DELETE FROM `service` WHERE idd={self.idd}")
     return time[0][0]
Example #19
0
 def __init__(self, id_owner):
     data = Querry(f"SELECT * FROM `tph` WHERE `id_owner`='{id_owner}'")
     id, self.id_owner, self.expiration, self.frequency = data[0]
     self.channel = ExistProfil(self.id_owner).location
Example #20
0
 def update_money(self, value):
     uptade = Querry(
         f"UPDATE `profil` SET `money`={self.money+value} WHERE idd={self.idd}"
     )
     return value
Example #21
0
 def save(self):
     data = Querry(f"UPDATE `vhl` SET `statut`={self.statut} WHERE `véhicule`='{self.vehicule}'")
Example #22
0
 def delete(self):
     Querry(f"DELETE FROM wh WHERE `name`='{self.name}'")
Example #23
0
 def update_lastuse(self):
     self.lastuse = __import__("time").time()
     Querry(
         f"UPDATE wh SET `lastuse`={self.lastuse} WHERE `name`='{self.name}'"
     )
Example #24
0
 def update_location(self, value):
     self.location = value
     uptade = Querry(
         f"UPDATE `profil` SET `location`={self.location} WHERE idd={self.idd}"
     )
     return value
Example #25
0
 def add_service_time(self, value):
     self.service_time += value
     uptade = Querry(
         f"UPDATE `profil` SET `service_time`={self.service_time} WHERE idd={self.idd}"
     )
     return value
Example #26
0
 def __init__(self, name):
     data = Querry(f"SELECT * FROM `vhl` WHERE `véhicule`='{name}'")
     #`id`, `statut`, `véhicule`, `cord`, `syno`, `required`
     id, self.statut, self.vehicule, self.cord, self.syno= data[0]
Example #27
0
    def __init__(self, idd):

        data = Querry(f"SELECT * FROM `profil` WHERE idd={idd}")
        id, self.idd, self.name, self.grade, self.hierarchie, self.poste, self.money, self.CP, self.location, self.service_time = data[
            0]
Example #28
0
 def __init__(self, alias):
     data = Querry(f"SELECT * FROM `wh` WHERE `alias`='{alias}'")
     id, self.alias, self.name, self.link, self.lastuse = data[0]
     self.expiration_str = time.ctime(self.lastuse + 2_592_000)
Example #29
0
 def drop(self):
     Querry(f"DELETE from bip WHERE `id_owner`={self.id_owner}")
Example #30
0
def get_all_vehicule(): return Querry("SELECT véhicule FROM vhl")