问题。是否可以在内联按钮中创建功能?同时,它会实现。电报机器人。电报机器人 ip 库。
主页
/
user-402307
leonardo's questions
学习在按钮中制作后退键。如何使它在调用时在文本中写入单击按钮的用户的名称?
bot.edit_message_text(
chat_id=call.message.chat.id, message_id=call.message.message_id,
text=("Привіт " + call.message.message_id.from_user.first_name +
"🥰!" +
"\n Я допоможу тобі роз рахувати твій конкурсний бал 🎲 ... "),
reply_markup=keyboardg)
编码
@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
if call.data == "mainmenu":
keyboardg = types.InlineKeyboardMarkup(row_width=1)
callback_button = types.InlineKeyboardButton(
text="Так ✔ ️💯", callback_data="test")
callback_button_1 = types.InlineKeyboardButton(
text="Ні ❌ ", callback_data="test_1")
keyboardg.add(callback_button, callback_button_1)
bot.edit_message_text(
chat_id=call.message.chat.id, message_id=call.message.message_id,
text=("Привіт " + call.message.message_id.from_user.first_name +
"🥰!" +
"\n Я допоможу тобі роз рахувати твій конкурсний бал 🎲 ... "),
reply_markup=keyboardg)
我从一本自学书上学习编程,我用一堂课解决了一个问题。
餐厅:创建一个名为Restaurant. 类方法必须包含两个属性__init__():和。创建一个输出两个属性的方法,以及一个显示餐厅营业消息的方法。从您的类中创建一个名为. 分别打印这两个属性,然后调用这两个方法。Restaurantrestaurant_namecuisine_typedescribe_restaurant()open_restaurant()restaurant
我的示例代码:
class Restaurant():
def _init_(self, name, tip):
self.name = name
self.tip = tip
def describe_restaurant():
print("Hello, visitor!" + self.name.title() + "welcome to you!")
def open_restaurant():
print("It is" + self.tip)
my_restaurant = ['natalia' , 'ukrainian']
print("Hello, visitor!")
print(describe_restaurant())
初学者编写代码,编写 2 个函数。请看并告诉我我编写的函数的替代方案以及错误是什么。不要严格判断。编码
def user_spisok(name, age):
for names in name:
print("\nHello,"+ name.title())
print("\ How are old you ? ")
for ages in age :
print(ages)
spisok ['eva', age = 13]
错误代码。
user_spisok(spisok)
File "user.py", line 7
spisok ['eva', age = 13]
^
SyntaxError: invalid syntax
Python 世界的新手。我为电报机器人编写了代码。我在pycharm中运行它,它说没有连接到服务器。Pycharm 已安装 pip,即 yTelegramBotAPI 库。不要严格判断。我不明白出了什么问题。pip 和 yTelegramBotAPI 库已安装新版本检查。代码:bot = telebot.TeleBot(')
@bot.message_handler(content_types=['text']) def get_text_messages(message): if message.text == "Hello":
bot.send_message(message.from_user.id, "Привет, сейчас я расскажу тебе гороскоп на сегодня.")
elif message.text == "/help":
bot.send_message(message.from_user.id, "Напиши Привет")
else:
bot.send_message(message.from_user.id, "Я тебя не понимаю. Напиши /help.")
bot.polling(none_stop=True, interval=0) 我知道代码一切正常。错误 :
2020-08-09 13:07:59,135 (util.py:68 PollingThread) ERROR - TeleBot: "ApiException occurred, args=('A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:\n[b\'{"ok":false,"error_code":409,"description":"Conflict: can\\\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}\']',)
Traceback (most recent call last):
File "D:\Soft\python\lib\site-packages\telebot\util.py", line 62, in run
task(*args, **kwargs)
File "D:\Soft\python\lib\site-packages\telebot\__init__.py", line 285, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
File "D:\Soft\python\lib\site-packages\telebot\__init__.py", line 255, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 206, in get_updates
return _make_request(token, method_url, params=payload)
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 69, in _make_request
return _check_result(method_name, result)['result']
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 88, in _check_result
raise ApiException(msg, method_name, result)
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: can\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}']
"
2020-08-09 13:07:59,136 (__init__.py:455 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: can\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}']"
2020-08-09 13:08:02,529 (util.py:68 PollingThread) ERROR - TeleBot: "ApiException occurred, args=('A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:\n[b\'{"ok":false,"error_code":409,"description":"Conflict: can\\\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}\']',)
Traceback (most recent call last):
File "D:\Soft\python\lib\site-packages\telebot\util.py", line 62, in run
task(*args, **kwargs)
File "D:\Soft\python\lib\site-packages\telebot\__init__.py", line 285, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
File "D:\Soft\python\lib\site-packages\telebot\__init__.py", line 255, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 206, in get_updates
return _make_request(token, method_url, params=payload)
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 69, in _make_request
return _check_result(method_name, result)['result']
2020-08-09 13:08:02,530 (__init__.py:455 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: can\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}']"
2020-08-09 13:08:03,140 (util.py:68 PollingThread) ERROR - TeleBot: "ApiException occurred, args=('A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:\n[b\'{"ok":false,"error_code":409,"description":"Conflict: can\\\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}\']',)
Traceback (most recent call last):
File "D:\Soft\python\lib\site-packages\telebot\util.py", line 62, in run
task(*args, **kwargs)
File "D:\Soft\python\lib\site-packages\telebot\__init__.py", line 285, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
File "D:\Soft\python\lib\site-packages\telebot\__init__.py", line 255, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 206, in get_updates
return _make_request(token, method_url, params=payload)
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 69, in _make_request
return _check_result(method_name, result)['result']
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 88, in _check_result
raise ApiException(msg, method_name, result)
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: can\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}']
2020-08-09 13:08:09,413 (__init__.py:455 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: can\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}']"
2020-08-09 13:08:13,531 (util.py:68 PollingThread) ERROR - TeleBot: "ApiException occurred, args=('A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:\n[b\'{"ok":false,"error_code":409,"description":"Conflict: can\\\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}\']',)
Traceback (most recent call last):
File "D:\Soft\python\lib\site-packages\telebot\util.py", line 62, in run
task(*args, **kwargs)
File "D:\Soft\python\lib\site-packages\telebot\__init__.py", line 285, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
File "D:\Soft\python\lib\site-packages\telebot\__init__.py", line 255, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 206, in get_updates
return _make_request(token, method_url, params=payload)
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 69, in _make_request
return _check_result(method_name, result)['result']
File "D:\Soft\python\lib\site-packages\telebot\apihelper.py", line 88, in _check_result
raise ApiException(msg, method_name, result)
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: can\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}']
"
2020-08-09 13:16:38,243 (__init__.py:455 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: can\'t use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}']"