电报api中有API方法,在Telethon中也有相同的API方法。但是,此方法没有将预期的答复/注释返回给帖子。相反,它返回多条消息,包括对请求的message_id的答复和其他消息,这些消息甚至不是对请求的message_id的答复。
for conv in client.iter_messages(channel.id):
if conv.reply_to:
# get parent message this message reply to
original_message = conv.get_reply_message()
tr
我试图将bot添加到通道中,但每次尝试都会收到以下错误消息:
telethon.errors.rpcerrorlist.BotMethodInvalidError: The API access for bot users is restricted. The method you tried to invoke cannot be executed as a bot
我的代码基本上是来自和这个的拷贝-pase。
和密码
from telethon.sync import TelegramClient, events, functions, types
from telethon.tl.typ
问题
我的"userbot“在新发布的渠道上留下评论
一些用户回复我的评论,这些回复出现在我的“回复”对话框中。
我想回复那些答复,但我也有同样的错误。
telethon.errors.rpcerrorlist.YouBlockedUserError: You blocked this user (caused by SendMessageRequest)
我在黑名单上没有任何用户
代码
这是我的消息处理程序
# id of "Replies" dialog
replies_chat_id = 1271266957
async def handle_message(
如何查看我的所有联系人并向他们发送消息?我使用Telethon (API电报python)。
from telethon.tl.functions.contacts import ResolveUsernameRequest
from telethon.tl.types import InputChannelEmpty
from telethon import TelegramClient
from telethon.tl.types.messages import Messages
from telethon.tl.types.contacts import Contacts
api_id
我已经在这里阅读了很多答案,并尝试了他们的代码,但我不能让示例为我工作,我也不明白为什么。
我想从电报通道捕获消息,但没有一种telehon方法对我有效……
我正在使用telethon,但如何使用并不重要。我只需要捕获这些消息。
from telethon import TelegramClient, events,utils
from telethon.tl.functions.messages import GetFullChatRequest
from telethon.tl.functions.messages import GetHistoryRequest
from teletho
我试图编写一个在另一个机器人上发送消息的机器人代码,我试着读取文档,但它无法工作:/这是当我与用户配对时得到的消息:
Sei stato inserito在聊天!
达蒂·戴尔大学
Scrivigli subito un messaggio
按钮1
按钮2
我需要用我输入的信息和一两秒钟后再输入一条消息来响应这个文本,但是代码只是停止了,甚至没有响应。下面是代码:
import asyncio
from telethon.sync import TelegramClient
from telethon import TelegramClient, events, sync
from t
我的程序应该用用户定义的文本回复用户帐户收到的电报消息。可以通过向电报机器人发送消息来更改此文本。对于机器人,我一直在使用PyTelegramBotAPI,为了从用户的帐户发送消息,我一直在使用Telethon。我可以通过调用bot.polling()来运行机器人,它工作得很好。Telethon客户端单独工作也很好,它有如下方法: async def run():
self.add_event_handler(self.message_handler, events.NewMessage)
while True:
#(Every Second the whi
嗨我真的很绝望..。 我试着用telethon做一个类似与电报机器人对话的测验。它应该看起来像这样: user1 > /start
bot > Hello who send you?
user1 > user0
bot > Thank you. So do you want in channel1 or channel2 or both?
user1 > channel1
*Bot invites the user 我使用了这个示例:https://arabic-telethon.readthedocs.io/en/stable/extra/examples/t
我希望从Telethon库中获得用户的id和first_name,使用GetContactsRequest方法,这样我就可以使用id发送消息,而不必对所有联系人的id进行硬编码。这是密码
from telethon.sync import TelegramClient
from telethon import functions, types
with TelegramClient('session', api_id, api_hash) as client:
result = client(functions.contacts.GetContactsRequest(