Я пытаюсь сделать так, чтобы пользователь запускал команду, бот спрашивал, готов ли пользователь, и если пользователь отвечал «да», бот продолжал выполнять команду.
@bot.command(name="mission")
async def mission(ctx):
scenarioslist = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10]
catnamelist = ['Mittens', 'Milo', 'Luna', 'Mochi', 'Tigger', 'Misty']
catcolorlist = ['Siamese', 'Persian', 'hairless', 'tabby', 'munchkin', 'Maine Coon']
catsizelist = ['', 'big', 'massive', 'small', 'tiny']
user = ctx.message.author
guild = ctx.guild.id
table = "PEOPLE_" + str(guild)
passfail1 = random.randint(1, 10)
passfail2 = random.randint(1, 9)
location = random.randint(1, 3)
scenarios = random.choice(scenarioslist)
catname = random.choice(catnamelist)
catcolor = random.choice(catcolorlist)
catsize = random.choice(catsizelist)
try:
connection = mysql.connector.connect(
host="localhost",
port="3306",
user="root",
password="root",
database="naruto_game"
)
cursor = connection.cursor()
sql_select_query = "SELECT * from " + table + " where user like '"+ str(ctx.message.author) +"'"
cursor.execute(sql_select_query)
record = cursor.fetchall()
for row in record:
if row[5] == "Genin" and row [6] < 800:
await ctx.send("You will be embarking on an F-Rank mission. Are you ready?")
msg = await bot.wait_for("message", check=lambda m: m.channel == ctx.channel and m.author == user)
decision = msg.content
if decision == "yes":
if passfail1 < 10:
if location == 1 and scenarios == [6]:
await ctx.send("Mrs. Nishina, one of the village elders, cat has gone missing. You've been assigned to find and return it to her.")
await asyncio.sleep(2)
await ctx.send(f"You go to Mrs. Nishina's home to find out as much information as you can about the cat. She tells you that her missing cat is a {catsize} {catcolor} cat named {catname}.")
elif passfail1 == 10:
if location == 1:
print("")
else:
await ctx.send(f"You didn't say {str('"yes"')}, so I'm ending the mission.")
except mysql.connector.Error as error:
print("Failed to find name: {}".format(error))
finally:
if connection.is_connected():
cursor.close()
connection.close()
print("MySQL connection has been closed.")
Я не получаю никаких ошибок при запуске кода, но бот не отвечает после того, как пользователь говорит «да». Я просмотрел другие вопросы и не нашел ничего, что помогло бы. Проблема может заключаться за пределами самой части пользовательского ввода.
sql_select_query = "SELECT * from " + table + " where user like '"+ str(ctx.message.author) +"'" cursor.execute(sql_select_query)
record = cursor.fetchall()
for row in record: if row[5] == "Genin" and row [6] < 800: await ctx.send("You will be embarking on an F-Rank mission. Are you ready?") msg = await bot.wait_for("message", check=lambda m: m.channel == ctx.channel and m.author == user)
decision = msg.content
if decision == "yes": if passfail1 < 10: if location == 1 and scenarios == [6]: await ctx.send("Mrs. Nishina, one of the village elders, cat has gone missing. You've been assigned to find and return it to her.") await asyncio.sleep(2) await ctx.send(f"You go to Mrs. Nishina's home to find out as much information as you can about the cat. She tells you that her missing cat is a {catsize} {catcolor} cat named {catname}.")
elif passfail1 == 10: if location == 1: print("")
else: await ctx.send(f"You didn't say {str('"yes"')}, so I'm ending the mission.")
except mysql.connector.Error as error: print("Failed to find name: {}".format(error)) finally: if connection.is_connected(): cursor.close() connection.close() print("MySQL connection has been closed.") [/code] Я не получаю никаких ошибок при запуске кода, но бот не отвечает после того, как пользователь говорит «да». Я просмотрел другие вопросы и не нашел ничего, что помогло бы. Проблема может заключаться за пределами самой части пользовательского ввода.
Я пытаюсь добавить функцию, которая спрашивает игрока, хочет ли он перезапустить, и если он набирает «да», игра должна перезапуститься.
elif response_turn3 == right :
print( You carry on down the path, whistling a merry tune. )
time.sleep(4)
print(...
Я новичок в Google Billing API. Использование версии 7.0 API. Я интегрирую его в клиент Android. Приложение еще не имеет бэкэнда. У меня есть две учетные записи внутреннего тестирования, которые тестируют приложение. Этот пользователь не подписался...
Первоначальная проблема: Установите менеджер пакетов nix, затем установите другие программы (например, lua), используя nix, запустив сценарий bash только один раз.
Решение: Я написал следующий bash-скрипт install.sh:
У меня есть фрагмент кода, который я могу выполнить, но для возврата результата (логического значения) потребуется около 90 секунд, но для моего случая этот результат не нужен. В программе, которую я использую, нет метода, пропускающего ожидание....