# --------------------------------------------------------------------------------- # Author: @shiro_hikka # Name: PMStat # Description: Defines how many messages did you and your chat partner write # Commands: stat # --------------------------------------------------------------------------------- # ยฉ Copyright 2025 # # ๐Ÿ”’ Licensed under the GNU AGPLv3 # ๐ŸŒ https://www.gnu.org/licenses/agpl-3.0.html # --------------------------------------------------------------------------------- # scope: hikka_only # meta developer: @shiro_hikka # meta banner: https://0x0.st/s/FIR0RnhUN5pZV5CZ6sNFEw/8KBz.jpg # --------------------------------------------------------------------------------- __version__ = (1, 0, 0) from .. import loader, utils from telethon.tl.types import Message @loader.tds class PMStat(loader.Module): """Defines how many messages did you and your chat partner write""" strings = { "name": "PMStat", "q": "๐Ÿ‘จโ€๐Ÿ’ป All in all, {} messages were counted from {}", "pm": "๐Ÿคจ Use in PM only" } async def statcmd(self, message: Message): """ [-p] [-s] - (-p - counts your chat partner messages) (-s - send result to the saved messages)""" args = utils.get_args_raw(message) if not message.is_private: return await utils.answer(message, self.strings["pm"]) await message.delete() chat = await self.client.get_entity(message.peer_id.user_id) target = "you" if "-p" not in args else f"{chat.first_name}" s = chat.id if "-s" not in args else self.tg_id count = 0 messagesList = [] async for i in self.client.iter_messages(chat.id): if "-p" in args: if i.from_id != self.tg_id: messagesList.append(i) else: if i.from_id == self.tg_id: messagesList.append(i) await message.client.send_message(s, self.strings["q"].format(len(messagesList), target))