Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
Minor bug fix in chat type identification due to the framework upgrade. Thanks for https://github.com/HithaishiDesai for reporting the same.
  • Loading branch information
m4mallu committed Aug 6, 2022
1 parent fead765 commit d859540
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
14 changes: 14 additions & 0 deletions library/chat_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import itertools
from presets import Presets
from library.sql import reset_all
from pyrogram.enums import ChatType
from pyrogram.errors import FloodWait
from plugins.cb_input import update_type_buttons
from library.sql import file_types, msg_id_limit, to_msg_id_cnf_db, master_index
Expand Down Expand Up @@ -104,3 +105,16 @@ async def set_to_defaults(id):
file_types.clear()
file_types.extend(Presets.FILE_TYPES)
await update_type_buttons()


# function to get the chat type of the source/target chat
async def get_chat_type(chat_status):
x = chat_status.type
chat_status = {
x == ChatType.CHANNEL: 'CHANNEL',
x == ChatType.SUPERGROUP: 'SUPERGROUP',
x == ChatType.GROUP: 'GROUP',
x == ChatType.PRIVATE: 'PRIVATE',
x == ChatType.BOT: 'BOT'
}.get(True)
return chat_status
8 changes: 4 additions & 4 deletions plugins/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pyrogram.types import Message
from pyrogram.enums import ParseMode
from pyrogram.errors import FloodWait
from library.chat_support import find_msg_id, find_dc
from library.chat_support import find_msg_id, find_dc, get_chat_type
from pyrogram import Client, filters, ContinuePropagation, StopPropagation
from library.buttons import (reply_markup_start, reply_markup_home, reply_markup_close,
reply_markup_cap_cnf, reply_markup_terminate)
Expand Down Expand Up @@ -131,7 +131,7 @@ async def force_reply_msg(client: Bot, message: Message):
await bot_msg.edit(Presets.SOURCE_CNF.format(
chat_status.title,
chat_id,
chat_status.type,
await get_chat_type(chat_status),
'@' + str(user_name) if bool(user_name) else "𝘗𝘳𝘪𝘷𝘢𝘵𝘦 𝘤𝘩𝘢𝘵",
dc_id if bool(dc_id) else "𝘊𝘩𝘢𝘵 𝘱𝘩𝘰𝘵𝘰 𝘳𝘦𝘲𝘶𝘪𝘳𝘦𝘥",
chat_status.members_count),
Expand Down Expand Up @@ -179,7 +179,7 @@ async def force_reply_msg(client: Bot, message: Message):
await bot_msg.edit(Presets.DEST_CNF.format(
chat_status.title,
chat_id,
chat_status.type,
await get_chat_type(chat_status),
'@' + str(user_name) if bool(user_name) else "𝘗𝘳𝘪𝘷𝘢𝘵𝘦 𝘤𝘩𝘢𝘵",
dc_id if bool(dc_id) else "𝘊𝘩𝘢𝘵 𝘱𝘩𝘰𝘵𝘰 𝘳𝘦𝘲𝘶𝘪𝘳𝘦𝘥",
chat_status.members_count),
Expand All @@ -194,7 +194,7 @@ async def force_reply_msg(client: Bot, message: Message):
await bot_msg.edit(Presets.DEST_CNF.format(
chat_status.title,
chat_id,
chat_status.type,
await get_chat_type(chat_status),
'@' + str(user_name) if bool(user_name) else "𝘗𝘳𝘪𝘷𝘢𝘵𝘦 𝘤𝘩𝘢𝘵",
dc_id if bool(dc_id) else "𝘊𝘩𝘢𝘵 𝘱𝘩𝘰𝘵𝘰 𝘳𝘦𝘲𝘶𝘪𝘳𝘦𝘥",
chat_status.members_count),
Expand Down

0 comments on commit d859540

Please sign in to comment.