In supergroups, my bot gets a message every time a user joins the group (by registering a MessageHandler
with ~filters.private
filter), so I know who it is (from the new_chat_members
field) and I can kick it if it doesn't meet certain conditions (e.g. it has no username set).
However, if I put the bot in a channel, I don't get any message when a user joins it (or, at least, not by using a MessageHandler
). Is it possible to get the same behavior?
Thanks
In Groups and Supergroups this works by Telegram sending a Service Message, which you receive via filters.new_chat_members
, or in groups >= 10 000 members via a ChatMemberUpdated
event (ie no new Message).
Channels do not have such an update, and thus you cannot handle anything like this. Your best bet is to periodically query the Recent Actions by using app.get_chat_event_log()
, and filter for the returned list for the events you want.