如何解决如何使用引荐链接加入电报聊天机器人?
这是我的程序代码:
chn = 'https://t.me/Crypto_Claimer_Bot?start=1003997020'
channel_entity = client.get_entity(chn)
print('LOGIN DENGAN @'+myself.username+'\n')
client.send_message(entity=channel_entity,message='/start')
运行程序时,会出现如下错误:
Traceback (most recent call last):
File "ulang.py",line 55,in <module>
channel_entity = client.get_entity(chn)
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/telethon/sync.py",line 39,in syncified
return loop.run_until_complete(coro)
File "/data/data/com.termux/files/usr/lib/python3.8/asyncio/base_events.py",line 616,in run_until_complete
return future.result()
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/telethon/client/users.py",line 311,in get_entity
result.append(await self._get_entity_from_string(x))
File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/telethon/client/users.py",line 546,in _get_entity_from_string
raise ValueError(
ValueError: Cannot find any entity corresponding to "https://t.me/Crypto_Claimer_Bot?start=1003997020"
解决方法
首先,您拥有的链接不是entity
。您应该可以将?
之前的链接部分用作实体。因此,最好将链接分为两部分。
link = 'https://t.me/Crypto_Claimer_Bot?start=1003997020'
bot_link,refereal = link.split('?')
message = f'/start {refereal.split('=')[1]}'
await client.send_message(bot_link,message)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。