Overview
A bot that automatically welcomes new members when they join a group or channel.Code
How It Works
- Participant Event - The
"participant"event fires when someone joins, leaves, or is added to a group - Check Join Type -
m.IsJoined()checks if user joined voluntarily,m.IsAdded()checks if user was added by admin - Get User Info -
m.User.FirstNamegets the first name of the user who joined - Send Welcome - Send a formatted welcome message to the group using
m.ChannelID() - HTML Formatting - Use
<b>tags for bold text in the welcome message
ParticipantUpdate Methods
m.IsJoined()- Returns true if user joined via invite linkm.IsAdded()- Returns true if user was added by an adminm.IsLeft()- Returns true if user left the groupm.IsKicked()- Returns true if user was removed/bannedm.IsBanned()- Returns true if user is banned from the groupm.ChannelID()- Returns the group/channel IDm.User- Contains user information (FirstName, Username, etc.)
Running the Example
- Replace
YOUR_APP_HASHwith your API hash - Replace
YOUR_BOT_TOKENwith your bot token from @BotFather - Add your bot to a group as admin
- Run the program:
- When someone joins the group, theyβll see a welcome message!
Customization Ideas
Next Steps
Get Chat Members
List all members in a group
Participant Updates
Learn more about participant updates