ソースを参照

fix: TypeError: 'Chat' object is not subscriptable

AttributeError: 'Message' object has no attribute 'message_id'
TheHamkerCat 3 年 前
親
コミット
971e27fa62
2 ファイル変更、10 行追加、10 行削除
  1. 9 9
      wbb/modules/create.py
  2. 1 1
      wbb/modules/misc.py

+ 9 - 9
wbb/modules/create.py

@@ -42,26 +42,26 @@ async def create(_, message):
     group_name = " ".join(split)
     desc = "Welcome To My " + ("Supergroup" if group_type == "s" else "Channel")
     if group_type == "b":  # for basicgroup
-        _id = await app2.create_group(group_name, BOT_USERNAME)
-        link = await app2.get_chat(_id["id"])
+        chat = await app2.create_group(group_name, BOT_USERNAME)
+        link = await app2.get_chat(chat.id)
         await eor(
             message,
-            text=f"**Basicgroup Created: [{group_name}]({link['invite_link']})**",
+            text=f"**Basicgroup Created: [{group_name}]({link.invite_link})**",
             disable_web_page_preview=True,
         )
     elif group_type == "s":  # for supergroup
-        _id = await app2.create_supergroup(group_name, desc)
-        link = await app2.get_chat(_id["id"])
+        chat = await app2.create_supergroup(group_name, desc)
+        link = await app2.get_chat(chat.id)
         await eor(
             message,
-            text=f"**Supergroup Created: [{group_name}]({link['invite_link']})**",
+            text=f"**Supergroup Created: [{group_name}]({link.invite_link})**",
             disable_web_page_preview=True,
         )
     elif group_type == "c":  # for channel
-        _id = await app2.create_channel(group_name, desc)
-        link = await app2.get_chat(_id["id"])
+        chat = await app2.create_channel(group_name, desc)
+        link = await app2.get_chat(chat.id)
         await eor(
             message,
-            text=f"**Channel Created: [{group_name}]({link['invite_link']})**",
+            text=f"**Channel Created: [{group_name}]({link.invite_link})**",
             disable_web_page_preview=True,
         )

+ 1 - 1
wbb/modules/misc.py

@@ -194,7 +194,7 @@ async def getid(client, message):
     text += f"**[Chat ID:](https://t.me/{chat.username})** `{chat.id}`\n\n"
     if not getattr(reply, "empty", True):
         id_ = reply.from_user.id if reply.from_user else reply.sender_chat.id
-        text += f"**[Replied Message ID:]({reply.link})** `{reply.message_id}`\n"
+        text += f"**[Replied Message ID:]({reply.link})** `{reply.id}`\n"
         text += f"**[Replied User ID:](tg://user?id={id_})** `{id_}`"
 
     await eor(