首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用TypeError时的Telethon EditBannedRequests

使用TypeError时的Telethon EditBannedRequests
EN

Stack Overflow用户
提问于 2020-10-16 13:29:58
回答 1查看 988关注 0票数 0

我想做的是:用户通过一个invite链接输入聊天,然后使用captcha获得额外的聊天(1n1和bot)。我读到EditBannedRequest应该做我想做的事但是..。我得到一个类型错误。我的EditBannedRequest现在基本是文档的例子.如果有人能帮忙那就太好了。

“守则”:

代码语言:javascript
复制
async def handler(event):
    chat = await event.get_chat()
        
    if isinstance(event.action_message.action, types.MessageActionChatJoinedByLink):
        global acitve_invite_link
        chat_to_add = await bot.get_entity('TestyTesyChatty')
        result = await bot(ExportChatInviteRequest(chat_to_add.id))
        acitve_invite_link = False
        temp = await bot.get_entity(event.action_message.from_id)
        await bot(EditBannedRequest(
                chat, temp, ChatBannedRights(
                    until_date=None,
                    view_messages=True
                )
        ))
...

错误:

代码语言:javascript
复制
DEBUG:telethon.network.mtprotosender:Handling RPC result for message 6884206512220131084
DEBUG:telethon.network.mtprotosender:Handling acknowledge for [6884206512264014408]
DEBUG:telethon.network.mtprotosender:Receiving items from the network...
DEBUG:telethon.network.mtprotosender:Handling RPC result for message 6884206512264014408
DEBUG:telethon.network.mtprotosender:Receiving items from the network...
DEBUG:telethon.extensions.messagepacker:Assigned msg_id = 6884206512487415476 to GetUsersRequest (20efd6344c0)
DEBUG:telethon.network.mtprotosender:Encrypting 1 message(s) in 44 bytes for sending
DEBUG:telethon.network.mtprotosender:Encrypted messages put in a queue to be sent
DEBUG:telethon.network.mtprotosender:Waiting for messages to send...
DEBUG:telethon.extensions.messagepacker:Assigned msg_id = 6884206512491466684 to MsgsAck (20efd634910)
DEBUG:telethon.network.mtprotosender:Encrypting 1 message(s) in 60 bytes for sending
DEBUG:telethon.network.mtprotosender:Encrypted messages put in a queue to be sent
DEBUG:telethon.network.mtprotosender:Waiting for messages to send...
DEBUG:telethon.network.mtprotosender:Handling RPC result for message 6884206512487415476
DEBUG:telethon.network.mtprotosender:Receiving items from the network...
ERROR:telethon.client.updates:Unhandled exception on handler
Traceback (most recent call last):
  File "C:\Just\a\Path\Python\Python38\site-packages\telethon\client\updates.py", line 443, in _dispatch_update
    await callback(event)
  File "C:\Just\another\path\telegram\enter_bot.py", line 191, in handler
    await bot(EditBannedRequest(
  File "C:\Just\a\Path\Python\Python38\site-packages\telethon\client\users.py", line 30, in __call__  
    return await self._call(self._sender, request, ordered=ordered)
  File "C:\Just\a\Path\Python\Python38\site-packages\telethon\client\users.py", line 37, in _call     
    await r.resolve(self, utils)
  File "C:\Just\a\Path\Python\Python38\site-packages\telethon\tl\functions\channels.py", line 304, in 
resolve
    self.channel = utils.get_input_channel(await client.get_input_entity(self.channel))
  File "C:\Just\a\Path\Python\Python38\site-packages\telethon\utils.py", line 263, in get_input_channel
    _raise_cast_fail(entity, 'InputChannel')
  File "C:\Just\a\Path\Python\Python38\site-packages\telethon\utils.py", line 138, in _raise_cast_fail
    raise TypeError('Cannot cast {} to any kind of {}.'.format(
TypeError: Cannot cast InputPeerChat to any kind of InputChannel.
INFO:telethon.network.mtprotosender:Disconnecting from 149.154.167.51:443/TcpFull...
DEBUG:telethon.network.mtprotosender:Closing current connection...
DEBUG:telethon.network.mtprotosender:Cancelling 0 pending message(s)...
INFO:telethon.network.mtprotosender:Disconnection from 149.154.167.51:443/TcpFull complete!
INFO:telethon.network.mtprotosender:Not disconnecting (already have no connection)

另一个问题是:

  1. 用户应该得到静音的->按一个按钮
  2. 在直接消息->中获得一个问题,如果错误被踢
  3. 如果是的话,那就应该平心静气了。

3.在本例中将如何工作。我是说我定了个时间

代码语言:javascript
复制
ChatBannedRights(
                    until_date=None,
                    view_messages=True
                )
        ))

until_date,这是否意味着用户会再次陷入沉默呢?还是有可能永远这样做?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-16 13:38:45

电报在聊天中不支持EditBannedRights,只有在超级群中才支持。转到官方电报客户端,并将新成员的历史记录更改为可见的,然后您的代码将工作。另外,您应该将chat更改为event.get_input_chat()

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64390153

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档