我想使用Telethon进行。
这是我的代码:
from telethon.tl.functions.channels import GetParticipantsRequest
from telethon.tl.types import ChannelParticipantsSearch
from time import sleep
api_id = 134565
api_hash = 'xxxxxx'
client = TelegramClient(None, api_id, api_hash)
client.connect()
if not client.is_use
使用下面的代码,我已经用telethon连接到电报大约一年了!
client = TelegramClient(
SESSION,
API_ID,
API_HASH
)
client.connect()
# the rest of my code
昨天,当我想用代码连接到我的会话时,我得到了这个错误:
telethon.errors.rpcerrorlist.AuthKeyDuplicatedError: An auth key with the same ID was already generated
错误不再显示,并且在中没有关于此
我的程序应该用用户定义的文本回复用户帐户收到的电报消息。可以通过向电报机器人发送消息来更改此文本。对于机器人,我一直在使用PyTelegramBotAPI,为了从用户的帐户发送消息,我一直在使用Telethon。我可以通过调用bot.polling()来运行机器人,它工作得很好。Telethon客户端单独工作也很好,它有如下方法: async def run():
self.add_event_handler(self.message_handler, events.NewMessage)
while True:
#(Every Second the whi
电报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
下面是我的代码:
import time
import telethon
import asyncio
# Enter your API ID and API hash here
api_id = 13******
api_hash = '8ba0a***********************'
# Enter the name of the text file containing the messages
message_file = 'messages.txt'
async def main():
# Connect to the Tele
如何查看我的所有联系人并向他们发送消息?我使用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
我正试图从一个私人电报频道获取信息。我是频道的一员,我可以在电报应用程序和电报网站上看到消息。
我尝试了下面的代码,该代码按预期工作,并为非私有信道打印消息。但是,当我输入私有通道的名称/ID时,输出是一个空字符串。
这是由于代码中的问题,还是无法通过Telethon访问私有消息?
谢谢。
async with client:
async for msg in client.iter_messages(client ID integer not string, 5):
print(msg.text)
我正在尝试抓取一个名为"Mothership.sg“的电报通道,尽管之前能够成功抓取所有通道消息,但似乎只能获取某个时间点的通道消息。下面是我的代码 from telethon import TelegramClient
##declare api_id, api_hash
async def afternoon():
async for message in client.iter_messages(-1001123464890):
print(message.id, message.text)
with TelegramClient('test
我正试图在一个我是管理员的私人电报频道中获取使用远程电视的用户列表,并将其打印到控制台。我用一个非私有的通道尝试了相同的代码,我也遇到了同样的问题。
我应该使用的用户名引用是什么?我不明白这是否是我的电报用户名,我的频道名称,我的好像我要在频道讲话,或什么。有人能帮忙吗?
from telethon import TelegramClient
from telethon.tl.functions.contacts import ResolveUsernameRequest
from telethon.tl.functions.channels import GetAdminL