onddyy
Coder
Hello, I am having errors while coding a telegram bot, I get this code by ChatGPT, and it says this error:
Traceback (most recent call last):
File "C:\Users\ohora\PycharmProjects\TelegramBot\.venv\bot.py", line 40, in <module>
main()
File "C:\Users\ohora\PycharmProjects\TelegramBot\.venv\bot.py", line 28, in main
updater = Updater(TOKEN)
^^^^^^^^^^^^^^
TypeError: Updater.init() missing 1 required positional argument: 'update_queue'
I wanna code an order bot for telegram.
from telegram.ext import Updater, CommandHandler, MessageHandler, filters
TOKEN = 'mytoken'
user_orders = {}
def start(update, context):
update.message.reply_text("Welcome! How can I assist you?")
def order(update, context):
update.message.reply_text("Please enter your order.")
def handle_order(update, context):
user = update.message.from_user
order_text = update.message.text
user_orders[user.id] = order_text
update.message.reply_text(f"Order received: {order_text}. Thank you!")
def show_order(update, context):
user = update.message.from_user
if user.id in user_orders:
order_text = user_orders[user.id]
update.message.reply_text(f"Your order: {order_text}")
else:
update.message.reply_text("You haven't placed an order yet.")
def main():
= Updater(TOKEN)
dp = updater.dispatcher
dp.add_handler(CommandHandler("start", start))
dp.add_handler(CommandHandler("order", order))
dp.add_handler(MessageHandler(Filters.text & ~Filters.command, handle_order))
dp.add_handler(CommandHandler("show_order", show_order))
updater.start_polling()
updater.idle()
if name == 'main':
main()
Traceback (most recent call last):
File "C:\Users\ohora\PycharmProjects\TelegramBot\.venv\bot.py", line 40, in <module>
main()
File "C:\Users\ohora\PycharmProjects\TelegramBot\.venv\bot.py", line 28, in main
updater = Updater(TOKEN)
^^^^^^^^^^^^^^
TypeError: Updater.init() missing 1 required positional argument: 'update_queue'
I wanna code an order bot for telegram.
from telegram.ext import Updater, CommandHandler, MessageHandler, filters
TOKEN = 'mytoken'
user_orders = {}
def start(update, context):
update.message.reply_text("Welcome! How can I assist you?")
def order(update, context):
update.message.reply_text("Please enter your order.")
def handle_order(update, context):
user = update.message.from_user
order_text = update.message.text
user_orders[user.id] = order_text
update.message.reply_text(f"Order received: {order_text}. Thank you!")
def show_order(update, context):
user = update.message.from_user
if user.id in user_orders:
order_text = user_orders[user.id]
update.message.reply_text(f"Your order: {order_text}")
else:
update.message.reply_text("You haven't placed an order yet.")
def main():
= Updater(TOKEN)
dp = updater.dispatcher
dp.add_handler(CommandHandler("start", start))
dp.add_handler(CommandHandler("order", order))
dp.add_handler(MessageHandler(Filters.text & ~Filters.command, handle_order))
dp.add_handler(CommandHandler("show_order", show_order))
updater.start_polling()
updater.idle()
if name == 'main':
main()