Page d'aide du casino

This commit is contained in:
attilavs2 2025-05-09 16:33:19 +02:00
parent 3d52bb4b94
commit 0d2d1fe52a

View file

@ -49,7 +49,7 @@ async def roll(message):
roll += str(random.randint(1,d)) + " " roll += str(random.randint(1,d)) + " "
else: else:
roll += str(random.randint(1,int(spec[0]))) roll += str(random.randint(1,int(spec[0])))
await message.channel.send(roll) await message.reply(roll)
async def pinguncon(message): async def pinguncon(message):
#fcalva's server #fcalva's server
@ -60,13 +60,13 @@ async def pinguncon(message):
elif message.guild.id == 1294017120631525416: elif message.guild.id == 1294017120631525416:
await message.channel.send("<@504751919760408617>") await message.channel.send("<@504751919760408617>")
else: else:
await message.channel.send("Pas dispo ici") await message.reply("Pas dispo ici")
async def pingjuif(message): async def pingjuif(message):
if message.guild.id in [1008485562304450610, 1157767629738618941]: if message.guild.id in [1008485562304450610, 1157767629738618941]:
await message.channel.send("<@459021187083927553>") await message.channel.send("<@459021187083927553>")
else: else:
message.channel.send("Pas dispo ici") message.channel.reply("Pas dispo ici")
async def pingrand(message): async def pingrand(message):
choice = random.choice(globals()["gmembers"][str(message.guild.id)]) choice = random.choice(globals()["gmembers"][str(message.guild.id)])
@ -82,8 +82,7 @@ async def reload(message):
else: else:
cursor.execute(f"UPDATE roulette SET shots = {shots} WHERE gid = {gid}") cursor.execute(f"UPDATE roulette SET shots = {shots} WHERE gid = {gid}")
database.commit() database.commit()
await message.channel.send("Revolver rechargé") await message.reply("Revolver rechargé")
async def roulette(message): async def roulette(message):
cursor.execute(f"CREATE TABLE IF NOT EXISTS roulette (gid INT PRIMARY KEY, shots INT)") cursor.execute(f"CREATE TABLE IF NOT EXISTS roulette (gid INT PRIMARY KEY, shots INT)")
@ -104,7 +103,7 @@ async def roulette(message):
await message.author.timeout(tdelt, reason="Vous avez perdu à la roulette...") await message.author.timeout(tdelt, reason="Vous avez perdu à la roulette...")
await message.channel.send(f"<@{uid}> s'est tiré une balle, et est dans un coma pendant 5 minutes") await message.channel.send(f"<@{uid}> s'est tiré une balle, et est dans un coma pendant 5 minutes")
except Exception as err: except Exception as err:
await message.channel.send("Une erreur s'est produite : `" + str(err) + "`") await message.reply("Une erreur s'est produite : `" + str(err) + "`")
nshots = random.randint(0,5) nshots = random.randint(0,5)
cursor.execute(f"UPDATE roulette SET shots = {nshots} WHERE gid = {gid}") cursor.execute(f"UPDATE roulette SET shots = {nshots} WHERE gid = {gid}")
database.commit() database.commit()
@ -112,7 +111,7 @@ async def roulette(message):
shots -= 1 shots -= 1
cursor.execute(f"UPDATE roulette SET shots = {shots} WHERE gid = {gid}") cursor.execute(f"UPDATE roulette SET shots = {shots} WHERE gid = {gid}")
database.commit() database.commit()
await message.channel.send("Clic... il n'y avait pas de cartouche dans la chambre...") await message.reply("Clic... il n'y avait pas de cartouche dans la chambre...")
async def casino_init(message): async def casino_init(message):
usrid = int(message.author.id) usrid = int(message.author.id)
@ -123,7 +122,7 @@ async def casino_init(message):
database.commit() database.commit()
await message.channel.send(f"Casino initialisé pour <@{usrid}>") await message.channel.send(f"Casino initialisé pour <@{usrid}>")
except: except:
await message.channel.send(f"Échec ! Réessayez plus tard") await message.reply(f"Échec ! Réessayez plus tard")
init_global_str = "Essayer d'initialiser le casino du serveur avec ?init" init_global_str = "Essayer d'initialiser le casino du serveur avec ?init"
init_perso_str = "Essayez d'initialiser votre portemonnaie avec ?init" init_perso_str = "Essayez d'initialiser votre portemonnaie avec ?init"
@ -134,11 +133,11 @@ async def balance(message):
try: try:
cash = cursor.execute(f"SELECT cash FROM tab_{gid} WHERE id={usrid}").fetchone() cash = cursor.execute(f"SELECT cash FROM tab_{gid} WHERE id={usrid}").fetchone()
except: except:
await message.channel.send(init_global_str) await message.reply(init_global_str)
if cash != None: if cash != None:
await message.channel.send(f"Vous avez {cash[0]}$") await message.reply(f"Vous avez {cash[0]}$")
else: else:
await message.channel.send(init_perso_str) await message.reply(init_perso_str)
async def collect(message): async def collect(message):
collect_gain = 50 collect_gain = 50
@ -150,11 +149,11 @@ async def collect(message):
try: try:
lst_coll = cursor.execute(f"SELECT lst_coll FROM tab_{gid} WHERE id={usrid}").fetchone()[0] lst_coll = cursor.execute(f"SELECT lst_coll FROM tab_{gid} WHERE id={usrid}").fetchone()[0]
except: except:
await message.channel.send(init_perso_str) await message.reply(init_perso_str)
return return
if lst_coll >= curr_time - cooldown: if lst_coll >= curr_time - cooldown:
rtime = (-curr_time + cooldown + lst_coll)//60 rtime = (-curr_time + cooldown + lst_coll)//60
await message.channel.send(f"Vous pourrez toucher votre RSA dans {rtime} minutes") await message.reply(f"Vous pourrez toucher votre RSA dans {rtime} minutes")
return return
cash = None cash = None
cash = cursor.execute(f"SELECT cash FROM tab_{gid} WHERE id={usrid}").fetchone() cash = cursor.execute(f"SELECT cash FROM tab_{gid} WHERE id={usrid}").fetchone()
@ -165,10 +164,10 @@ async def collect(message):
cursor.execute(f"UPDATE tab_{gid} SET cash = {cash} WHERE id={usrid}") cursor.execute(f"UPDATE tab_{gid} SET cash = {cash} WHERE id={usrid}")
database.commit() database.commit()
nc = cooldown//60 nc = cooldown//60
await message.channel.send(f"Vous avez recu {collect_gain}$ en RSA. Vous avez désormais {cash}$\n"\ await message.reply(f"Vous avez recu {collect_gain}$ en RSA. Vous avez désormais {cash}$\n"\
f"Revenez dans {nc} minutes pour votre prochain chèque") f"Revenez dans {nc} minutes pour votre prochain chèque")
else: else:
await message.channel.send(init_perso_str) await message.reply(init_perso_str)
async def slot(message): async def slot(message):
amnt = message.content.split(' ')[1] amnt = message.content.split(' ')[1]
@ -181,11 +180,11 @@ async def slot(message):
uid = int(message.author.id) uid = int(message.author.id)
ret = cursor.execute(f"SELECT cash FROM tab_{gid} WHERE id={uid}").fetchone() ret = cursor.execute(f"SELECT cash FROM tab_{gid} WHERE id={uid}").fetchone()
if ret == None: if ret == None:
await message.channel.send(init_perso_str) await message.reply(init_perso_str)
return return
cash = ret[0] cash = ret[0]
if amnt > cash: if amnt > cash:
await message.channel.send("Vous n'avez pas assez d'argent") await message.reply("Vous n'avez pas assez d'argent")
return return
roll = random.random() roll = random.random()
gain = 0 gain = 0
@ -202,7 +201,7 @@ async def slot(message):
await message.channel.send(f"<@{uid}> a extrait {gain}$ des griffes de la machine") await message.channel.send(f"<@{uid}> a extrait {gain}$ des griffes de la machine")
if roll >= 19/20: if roll >= 19/20:
gain = int(round(amnt*4 + amnt*17*random.random())) gain = int(round(amnt*4 + amnt*17*random.random()))
await message.channel.send(f"## <@{uid}> JACKPOT ! Vous avez gagné {gain}$ !") await message.channel.send(f"# <@{uid}> JACKPOT ! Vous avez gagné {gain}$ !")
cash -= amnt-gain cash -= amnt-gain
cursor.execute(f"UPDATE tab_{gid} SET cash = {cash} WHERE id={uid}") cursor.execute(f"UPDATE tab_{gid} SET cash = {cash} WHERE id={uid}")
database.commit() database.commit()
@ -220,7 +219,7 @@ async def leaderboard(message):
ucash = result[i][1] ucash = result[i][1]
msgstr += " "+str(i+1)+f". <@{uid}> - {ucash}$\n" msgstr += " "+str(i+1)+f". <@{uid}> - {ucash}$\n"
i += 1 i += 1
await message.channel.send(msgstr, allowed_mentions=discord.AllowedMentions().none()) await message.reply(msgstr, allowed_mentions=discord.AllowedMentions().none())
async def transfer(message): async def transfer(message):
split = message.content.split(" ") split = message.content.split(" ")
@ -230,33 +229,43 @@ async def transfer(message):
uid = int(message.author.id) uid = int(message.author.id)
utili = cursor.execute(f"SELECT * FROM tab_{gid} WHERE id={uid}").fetchone() utili = cursor.execute(f"SELECT * FROM tab_{gid} WHERE id={uid}").fetchone()
if utili == None: if utili == None:
await message.channel.send(init_perso_str) await message.reply(init_perso_str)
return return
try: try:
tid = int(split[1].strip("<@").rstrip(">")) tid = int(split[1].strip("<@").rstrip(">"))
except: except:
await message.channel.send("Destinataire invalide") await message.reply("Destinataire invalide")
return return
target = cursor.execute(f"SELECT * FROM tab_{gid} WHERE id={tid}").fetchone() target = cursor.execute(f"SELECT * FROM tab_{gid} WHERE id={tid}").fetchone()
if target == None: if target == None:
await message.channel.send("Destinataire non initialisé") await message.reply("Destinataire non initialisé ou inexistant")
return return
amnt = 0 amnt = 0
try: try:
amnt = int(split[2]) amnt = int(split[2])
except: except:
await message.channel.send("Quantité non valide") await message.reply("Quantité non valide")
return return
taxamnt = int(round(amnt*0.05)) taxamnt = int(round(amnt*0.05))
if amnt + taxamnt > utili[1]: if amnt + taxamnt > utili[1]:
await message.channel.send("Vous n'avez pas assez d'argent") await message.reply("Vous n'avez pas assez d'argent")
return return
ncashu = utili[1] - amnt - taxamnt ncashu = utili[1] - amnt - taxamnt
ncasht = target[1] + amnt ncasht = target[1] + amnt
cursor.execute(f"UPDATE tab_{gid} SET cash={ncashu} WHERE id={uid}") cursor.execute(f"UPDATE tab_{gid} SET cash={ncashu} WHERE id={uid}")
cursor.execute(f"UPDATE tab_{gid} SET cash={ncasht} WHERE id={tid}") cursor.execute(f"UPDATE tab_{gid} SET cash={ncasht} WHERE id={tid}")
database.commit() database.commit()
await message.channel.send(f"Transfert effectué. Une taxe de 5% ({taxamnt}) a été prélevée.") await message.reply(f"Transfert effectué. Une taxe de 5% ({taxamnt}$) a été prélevée.")
async def casino_aide(message):
await message.channel.send("Commandes du casino Eco+\n"\
"?init : initialiser votre portefeuille\n"\
"?collect : Collectez votre revenu\n"\
"?cash : Consultez l'état de vos finances\n"\
"?lb : Consultez le top 5 des joueurs les plus riches\n"
"?transfer @dest <qtt> : Transférez <qtt> dollars à @dest\n"\
" (Une taxe de 5% est appliquée)\n"\
"?slot <qtt> : Jouez à la machine à sous avec une mise de <qtt>\n")
async def ecoaide(message): async def ecoaide(message):
await message.channel.send("Eco+, un bot Eco plus pour faire des conneries\n"\ await message.channel.send("Eco+, un bot Eco plus pour faire des conneries\n"\
@ -264,13 +273,16 @@ async def ecoaide(message):
"?pingunjuif : Ping le juif local\n"\ "?pingunjuif : Ping le juif local\n"\
"?pingrand : Ping un membre aléatoire du serveur\n"\ "?pingrand : Ping un membre aléatoire du serveur\n"\
"?roulette : Jouez à la roulette russe\n"\ "?roulette : Jouez à la roulette russe\n"\
"?reload : Réinitialisez la roulette russe\n") "?reload : Réinitialisez la roulette russe\n"\
"?casino : Page d'aide du casino")
async def ecohelp(message): async def ecohelp(message):
await message.channel.send("Eco+ help page \n"\ await message.channel.send("Eco+ help page \n"\
"?pinguncon : Ping the local dumbass\n"\ "?pinguncon : Ping the local dumbass\n"\
"?pingrand : Ping a random user\n"\ "?pingrand : Ping a random user\n"\
"?roulette : Take one shot on six to get timed out") "?roulette : Play russian roulette\n"\
"?reload : Reset the russian roulette\n"\
"?casino_en : English help page for the casino")
async def hello(message): async def hello(message):
await message.channel.send('henlo') await message.channel.send('henlo')
@ -357,6 +369,7 @@ cmd_dict = {\
"?slot":slot,\ "?slot":slot,\
"?roll":roll,\ "?roll":roll,\
"?transfer":transfer,\ "?transfer":transfer,\
"?casino":casino_aide,\
} }
@client.event @client.event
@ -371,14 +384,14 @@ async def on_message(message):
if content[0] != "?": if content[0] != "?":
return return
if not content in cmd_dict: if not content in cmd_dict:
await message.channel.send("Commande non reconnue !") await message.reply("Commande non reconnue !")
return return
try: try:
await cmd_dict[content](message) await cmd_dict[content](message)
except Exception as err: except Exception as err:
print(err) print(err)
await message.channel.send("Une erreur s'est produite : `" + str(err) + "`") await message.reply("Une erreur s'est produite : `" + str(err) + "`")
def do_forgejo_thread(): def do_forgejo_thread():
forgejo.app.run(port=5000) forgejo.app.run(port=5000)