gpt4 book ai didi

python - 并非所有组都在 Telethon 中可见

转载 作者:行者123 更新时间:2023-12-02 03:08:57 25 4
gpt4 key购买 nike

我正在使用chat.megagroup==true它没有显示所有 channel (在m==1中),它还存在一些问题,例如有时显示 A 组和 B 组,有时显示 A 或 B,有时显示 C 组,不知道为什么会发生这种情况,甚至没有更改代码中的任何内容。

该脚本总体工作正常,但唯一的问题是我有时没有需要使用的组。

result = client(GetDialogsRequest(
offset_date=last_date,
offset_id=0,
offset_peer=InputPeerEmpty(),
limit=chunk_size,
hash = 0))

chats.extend(result.chats)
dialogs = client.get_dialogs()

m = input("1: For only permitted groups \n2: For all groups\n")
if m=='1':
for chat in chats:
try:
if chat.megagroup == True:
groups.append(chat)
except:
continue
elif m=='2':
for i in dialogs:
try:
i.entity.status
except:
groups.append(i)
continue

m==2中,显示了所有组。你能指导一下我做错了什么还是别的什么?

最佳答案

GetDialogsRequest 是一个原始请求,Telegram 对其的最大限制为 100。您不应该使用它,并且您应该始终更喜欢使用 client.get_dialogs()。您可以使用dialog.is_group检查它是否是一个组,以及使用dialog.is_channel检查它是否是一个 channel 。因此,对于大型集团来说:

if dialog.is_group and dialog.is_channel:
# it's a megagroup (= supergroup)

这些属性可以在 https://docs.telethon.dev/en/latest/modules/custom.html#telethon.tl.custom.dialog.Dialog 的文档中找到。 .

关于python - 并非所有组都在 Telethon 中可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58237367/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com