Created
October 16, 2022 18:52
-
-
Save KeshavSharmaWeb/2adf8f5eca029e7f9a9fce5879cd40db to your computer and use it in GitHub Desktop.
Telegram Bot for greeting new users in the group using Python - Telebot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install pyTelegramBotAPI | |
import json | |
from telebot import types | |
import telebot | |
token = "ENTER-YOUR-ACCESS-TOKEN-HERE" | |
bot = telebot.TeleBot(token) | |
def greet_user(messages): | |
for message in messages: | |
for new_member in message.new_chat_members: | |
bot.send_message(message.chat.id, f'Welcome {new_member.first_name} to the group!') | |
bot.set_update_listener(greet_user) | |
if __name__ == '__main__': | |
bot.infinity_polling() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment