Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed the bug #17

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ def handle_response(text: str):
return 'Hey there! Type /price to check cryptocurrency prices.'
return 'I can help you check cryptocurrency prices. Type /price to start.'

# Function to greet new members
async def greet_new_member(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
for new_member in update.message.new_chat_members:
await update.message.reply_text(f"Welcome {new_member.first_name}! Enjoy using the Crypto Bot!")

# Error handling
async def error(update: Update, context: ContextTypes.DEFAULT_TYPE):
print(f"Update {update} caused error {context.error}")
Expand All @@ -73,9 +78,12 @@ async def error(update: Update, context: ContextTypes.DEFAULT_TYPE):
# Button handler
app.add_handler(CallbackQueryHandler(button))

# Message Handler
# Message Handler for incoming messages
app.add_handler(MessageHandler(filters.TEXT, handle_message))

# Message Handler for new chat members
app.add_handler(MessageHandler(filters.StatusUpdate.NEW_CHAT_MEMBERS, greet_new_member))

# Error Handler
app.add_error_handler(error)

Expand Down