some changes
This commit is contained in:
parent
b12298ebeb
commit
83f1e8f495
32
gesmain.py
32
gesmain.py
@ -1,4 +1,4 @@
|
||||
import discord, csv, os, datetime
|
||||
import discord, csv, os, datetime, random
|
||||
from discord import app_commands
|
||||
from discord.ext import commands
|
||||
|
||||
@ -35,6 +35,15 @@ async def logfile(guildid, process, message):
|
||||
file = open(f'guild_data/guild_{guildid}.log', 'a')
|
||||
file.write(f"[{time}] {process} {message}\n")
|
||||
|
||||
async def kratsi(val1, val2):
|
||||
values = [val1, val2]
|
||||
if val2 == val1:
|
||||
return(random.choice(values))
|
||||
elif val1 > val2:
|
||||
return(val2)
|
||||
elif val2 > val1:
|
||||
return(val1)
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
@ -98,10 +107,27 @@ async def guess(interaction: discord.Interaction, meaning: str):
|
||||
|
||||
else:
|
||||
solution = (await precti(guildid, "fraze")).lower()
|
||||
pzkratka = await precti(guildid, 'zkratka')
|
||||
guess = meaning.lower()
|
||||
|
||||
if solution != guess:
|
||||
await interaction.response.send_message(f"{interaction.user.nick}'s guess **({meaning})** is incorrect!")
|
||||
if solution != guess:
|
||||
solution = solution.split(" ")
|
||||
guess = guess.split(" ")
|
||||
napoveda = "\n__but the words in this order are guessed correctly:__"
|
||||
trefil = 0
|
||||
|
||||
for i in range(await kratsi(len(solution), len(guess))):
|
||||
if guess[i] == solution[i]:
|
||||
napoveda += f"\n {guess[i]}"
|
||||
trefil = 1
|
||||
else:
|
||||
napoveda += "\n XXX"
|
||||
response = f"{interaction.user.nick}'s guess **({meaning})** is incorrect **({pzkratka})**!"
|
||||
|
||||
if trefil == 1:
|
||||
response += napoveda
|
||||
|
||||
await interaction.response.send_message(response)
|
||||
|
||||
if solution == guess:
|
||||
await interaction.response.send_message(f"{interaction.user.nick} have succesfully guessed {riddle_author.nick}'s riddle **({solution.lower()})**")
|
||||
|
Loading…
Reference in New Issue
Block a user