@@ -110,13 +110,20 @@ async def type_afk_is_not_true(notafk):
110110 str (len (USERS )) + " chats while you were away" ,
111111 )
112112 for i in USERS :
113- name = await notafk .client .get_entity (i )
114- name0 = str (name .first_name )
115- await notafk .client .send_message (
116- BOTLOG_CHATID ,
117- "[" + name0 + "](tg://user?id=" + str (i ) + ")" +
118- " sent you " + "`" + str (USERS [i ]) + " messages`" ,
119- )
113+ if str (i ).isnumeric ():
114+ name = await notafk .client .get_entity (i )
115+ name0 = str (name .first_name )
116+ await notafk .client .send_message (
117+ BOTLOG_CHATID ,
118+ "[" + name0 + "](tg://user?id=" + str (i ) + ")" +
119+ " sent you " + "`" + str (USERS [i ]) + " message(s)`" ,
120+ )
121+ else : # anon admin
122+ await notafk .client .send_message (
123+ BOTLOG_CHATID ,
124+ "Anonymous admin in `" + i + "` sent you " + "`" +
125+ str (USERS [i ]) + " message(s)`" ,
126+ )
120127 COUNT_MSG = 0
121128 USERS = {}
122129 AFKREASON = None
@@ -167,22 +174,33 @@ async def mention_afk(mention):
167174 is_bot = False
168175 if (sender := await mention .get_sender ()):
169176 is_bot = sender .bot
170- if not is_bot and mention .sender_id not in USERS :
177+ if is_bot : return # ignore bot
178+
179+ chat_obj = await mention .client .get_entity (mention .chat_id )
180+ chat_title = chat_obj .title
181+
182+ if mention .sender_id not in USERS or chat_title not in USERS :
171183 if AFKREASON :
172184 await mention .reply (f"I'm AFK since { afk_since } .\
173185 \n Reason: `{ AFKREASON } `" )
174186 else :
175187 await mention .reply (str (choice (AFKSTR )))
176- USERS .update ({mention .sender_id : 1 })
177- elif not is_bot and sender :
188+ if mention .sender_id is not None :
189+ USERS .update ({mention .sender_id : 1 })
190+ else :
191+ USERS .update ({chat_title : 1 })
192+ else :
178193 if USERS [mention .sender_id ] % randint (2 , 4 ) == 0 :
179194 if AFKREASON :
180195 await mention .reply (f"I'm still AFK since { afk_since } .\
181196 \n Reason: `{ AFKREASON } `" )
182197 else :
183198 await mention .reply (str (choice (AFKSTR )))
184- USERS [mention .sender_id ] = USERS [mention .sender_id ] + 1
185- COUNT_MSG = COUNT_MSG + 1
199+ if mention .sender_id is not None :
200+ USERS [mention .sender_id ] += 1
201+ else :
202+ USERS [chat_title ] += 1
203+ COUNT_MSG += 1
186204
187205
188206@register (incoming = True , disable_errors = True )
0 commit comments