如何使用推荐 link 加入电报聊天机器人?
How can I join the telegram chat bot using the referral link?
这是我的程序代码:
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"
从这个错误中,我应该在我的程序代码中更改什么?
首先,您拥有的 link 不是 entity
。您应该能够将 ?
之前的 link 部分用作实体。所以你最好把 link 分成两部分。
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)
这是我的程序代码:
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"
从这个错误中,我应该在我的程序代码中更改什么?
首先,您拥有的 link 不是 entity
。您应该能够将 ?
之前的 link 部分用作实体。所以你最好把 link 分成两部分。
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)