MCPcopy Index your code
hub / github.com/python-telegram-bot/python-telegram-bot / greet_chat_members

Function greet_chat_members

examples/chatmemberbot.py:116–135  ·  view source on GitHub ↗

Greets new users in chats and announces when someone leaves

(update: Update, context: ContextTypes.DEFAULT_TYPE)

Source from the content-addressed store, hash-verified

114
115
116async def greet_chat_members(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
117 """Greets new users in chats and announces when someone leaves"""
118 result = extract_status_change(update.chat_member)
119 if result is None:
120 return
121
122 was_member, is_member = result
123 cause_name = update.chat_member.from_user.mention_html()
124 member_name = update.chat_member.new_chat_member.user.mention_html()
125
126 if not was_member and is_member:
127 await update.effective_chat.send_message(
128 f"{member_name} was added by {cause_name}. Welcome!",
129 parse_mode=ParseMode.HTML,
130 )
131 elif was_member and not is_member:
132 await update.effective_chat.send_message(
133 f"{member_name} is no longer with us. Thanks a lot, {cause_name} ...",
134 parse_mode=ParseMode.HTML,
135 )
136
137
138async def start_private_chat(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:

Callers

nothing calls this directly

Calls 3

extract_status_changeFunction · 0.85
mention_htmlMethod · 0.45
send_messageMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…