Browse Source

Get Info about unread messages.

Nicolas "Colin" Neht 4 months ago
parent
commit
c24841982d
2 changed files with 33 additions and 2 deletions
  1. 1
    0
      HELP.md
  2. 32
    2
      pyrobot/modules/get_info.py

+ 1
- 0
HELP.md View File

@@ -71,6 +71,7 @@ Get information about your administration, members of your chat and all your cha
71 71
 | `!members` | Gives out counter of all members, bots and deleted accounts in that group. |
72 72
 | `.id` | Gives out the File ID of a replied-to media. If there is neither a media nor a reply it will be the Chat ID. |
73 73
 | `!chats` | Get an overview on how many chats you have in groups, supergroup, with bots, etc. |
74
+| `!unread` | Get an overview on unread messages, mentions and chats marked as unread |
74 75
 
75 76
 ### Memes (`memes.py`)
76 77
 

+ 32
- 2
pyrobot/modules/get_info.py View File

@@ -41,8 +41,17 @@ CHAT_INFO = (
41 41
     "║ Channels: {}\n"
42 42
     "╠═════════\n"
43 43
     "║ Time elapsed: {} seconds\n"
44
-    "╚═════════"
45
-)
44
+    "╚═════════")
45
+
46
+UNREAD_INFO = (
47
+    "╔═════════\n"
48
+    "║ **Overview Unreads**\n"
49
+    "║ Total Chats: {}\n"
50
+    "╠═════════\n"
51
+    "║ Unread Messages: {}\n"
52
+    "║ Unread Mentions: {}\n"
53
+    "║ Marked unread: {}\n"
54
+    "╚═════════")
46 55
 
47 56
 # -- Constants End -- #
48 57
 
@@ -216,3 +225,24 @@ def get_chats(bot: BOT, message: Message):
216 225
         supergroup,
217 226
         channel,
218 227
         int(time()) - start))
228
+
229
+
230
+@BOT.on_message(Filters.command("unread", "!") & Filters.me)
231
+def get_unreads(bot: BOT, message: Message):
232
+    all_dialogs = 0
233
+    total_unreads = 0
234
+    total_mentions = 0
235
+    marked_unread = 0
236
+
237
+    message.edit("Getting Dialogs...")
238
+    for dialog in BOT.iter_dialogs():
239
+        all_dialogs += 1
240
+        total_unreads += dialog.unread_messages_count
241
+        total_mentions += dialog.unread_mentions_count
242
+        marked_unread += dialog.unread_mark
243
+
244
+    message.edit(UNREAD_INFO.format(
245
+        all_dialogs,
246
+        total_unreads,
247
+        total_mentions,
248
+        marked_unread))

Loading…
Cancel
Save