roulette v2
This commit is contained in:
parent
7e2cab687a
commit
32d0433b5c
1 changed files with 58 additions and 8 deletions
66
ecoplus.py
66
ecoplus.py
|
@ -60,16 +60,47 @@ async def pingrand(message):
|
||||||
choice = random.choice(globals()["gmembers"][str(message.guild.id)])
|
choice = random.choice(globals()["gmembers"][str(message.guild.id)])
|
||||||
await message.channel.send("<@"+str(choice.id)+">")
|
await message.channel.send("<@"+str(choice.id)+">")
|
||||||
|
|
||||||
|
async def reload(message):
|
||||||
|
cursor.execute(f"CREATE TABLE IF NOT EXISTS roulette (gid INT PRIMARY KEY, shots INT)")
|
||||||
|
gid = int(message.guild.id)
|
||||||
|
ret = cursor.execute(f"SELECT shots FROM roulette WHERE gid = {gid}").fetchone()
|
||||||
|
shots = random.randint(0,5)
|
||||||
|
if ret == None:
|
||||||
|
cursor.execute(f"INSERT INTO roulette (gid,shots) VALUES ({gid},{shots})")
|
||||||
|
else:
|
||||||
|
cursor.execute(f"UPDATE roulette SET shots = {shots} WHERE gid = {gid}")
|
||||||
|
database.commit()
|
||||||
|
await message.channel.send("Revolver rechargé")
|
||||||
|
|
||||||
|
|
||||||
async def roulette(message):
|
async def roulette(message):
|
||||||
roll = random.random()
|
cursor.execute(f"CREATE TABLE IF NOT EXISTS roulette (gid INT PRIMARY KEY, shots INT)")
|
||||||
if roll < 0.16666666666:
|
database.commit()
|
||||||
tdelt = datetime.timedelta(minutes=1)
|
gid = int(message.guild.id)
|
||||||
|
ret = cursor.execute(f"SELECT shots FROM roulette WHERE gid = {gid}").fetchone()
|
||||||
|
if ret == None:
|
||||||
|
shots = random.randint(0,5)
|
||||||
|
cursor.execute(f"INSERT INTO roulette (gid,shots) VALUES ({gid},{shots})")
|
||||||
|
database.commit()
|
||||||
|
else:
|
||||||
|
shots = ret[0]
|
||||||
|
print("Shots : ", shots)
|
||||||
|
if shots <= 0:
|
||||||
|
tdelt = datetime.timedelta(minutes=5)
|
||||||
|
uid = message.author.id
|
||||||
try:
|
try:
|
||||||
await message.author.timeout(tdelt, reason="Vous avez perdu à la roulette...")
|
await message.author.timeout(tdelt, reason="Vous avez perdu à la roulette...")
|
||||||
except:
|
await message.channel.send(f"<@{uid}> s'est tiré une balle, et est dans un coma pendant 5 minutes")
|
||||||
await message.channel.send("Une erreur s'est produite ! (Je ne peux probablement pas vous timeout)")
|
except Exception as err:
|
||||||
|
await message.channel.send("Une erreur s'est produite : `" + str(err) + "`")
|
||||||
|
nshots = random.randint(0,5)
|
||||||
|
cursor.execute(f"UPDATE roulette SET shots = {nshots} WHERE gid = {gid}")
|
||||||
|
database.commit()
|
||||||
else:
|
else:
|
||||||
await message.channel.send("Ouf ! Il n'y avait pas de cartouche dans la chambre...")
|
shots -= 1
|
||||||
|
cursor.execute(f"UPDATE roulette SET shots = {shots} WHERE gid = {gid}")
|
||||||
|
database.commit()
|
||||||
|
await message.channel.send("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)
|
||||||
|
@ -126,6 +157,21 @@ async def collect(message):
|
||||||
else:
|
else:
|
||||||
await message.channel.send(init_perso_str)
|
await message.channel.send(init_perso_str)
|
||||||
|
|
||||||
|
async def leaderboard(message):
|
||||||
|
uid = int(message.author.id)
|
||||||
|
gid = int(message.guild.id)
|
||||||
|
lb = None
|
||||||
|
result = cursor.execute(f"SELECT * FROM tab_{gid} ORDER BY cash DESC").fetchall()
|
||||||
|
msgstr = "## ===== Leaderboard =====\n"
|
||||||
|
i = 0
|
||||||
|
rlen = len(result)
|
||||||
|
while i < 10 and i < rlen:
|
||||||
|
uid = result[i][0]
|
||||||
|
ucash = result[i][1]
|
||||||
|
msgstr += " "+str(i+1)+f". <@{uid}> - {ucash}$\n"
|
||||||
|
i += 1
|
||||||
|
await message.channel.send(msgstr, allowed_mentions=discord.AllowedMentions().none())
|
||||||
|
|
||||||
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"\
|
||||||
"?pinguncon : Ping le con local\n"\
|
"?pinguncon : Ping le con local\n"\
|
||||||
|
@ -219,6 +265,8 @@ cmd_dict = {\
|
||||||
"?init":casino_init,\
|
"?init":casino_init,\
|
||||||
"?cash":balance,\
|
"?cash":balance,\
|
||||||
"?collect":collect,\
|
"?collect":collect,\
|
||||||
|
"?lb":leaderboard,\
|
||||||
|
"?reload":reload,\
|
||||||
}
|
}
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
|
@ -232,15 +280,17 @@ async def on_message(message):
|
||||||
return
|
return
|
||||||
if content[0] != "?":
|
if content[0] != "?":
|
||||||
return
|
return
|
||||||
|
if not content in cmd_dict:
|
||||||
|
await message.channel.send("Commande non reconnue !")
|
||||||
|
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("Commande non reconnue !")
|
await message.channel.send("Une erreur s'est produite : `" + str(err) + "`")
|
||||||
|
|
||||||
def do_forgejo_thread():
|
def do_forgejo_thread():
|
||||||
print("229")
|
|
||||||
forgejo.app.run(port=5000)
|
forgejo.app.run(port=5000)
|
||||||
|
|
||||||
forgejo_thread = threading.Thread()
|
forgejo_thread = threading.Thread()
|
||||||
|
|
Loading…
Add table
Reference in a new issue