[英]Read telegram group message
我屬於一個電報組。 我想在我的python代碼中讀取這些消息。 有什么方法可以讀取這些消息而無需在該組中添加漫游器。例如,abc是我的用戶ID ...並且abc已添加到xyz組中。 因此想在我的python代碼中讀取xyz組消息。
是的,您可以使用名為Telethon的電報API來實現。
這是設置Telethon API流程的示例。 我已編寫此代碼,以從一個電報組中提取所有新發布的圖像。 它將使您了解如何開始使用它。
import sys
import os
from telethon import TelegramClient
from telethon.tl.functions.messages import GetFullChatRequest
from telethon.tl.functions.messages import GetHistoryRequest
from telethon.tl.functions.channels import GetChannelsRequest
from telethon.tl.functions.contacts import ResolveUsernameRequest
from telethon.tl.types import PeerUser, PeerChat, PeerChannel
import re
# These example values won't work. You must get your own api_id and
# api_hash from https://my.telegram.org, under API Development.
api_id = 11111 #number
api_hash = 'x'#string
phone = 'x'
client = TelegramClient('session_name', api_id, api_hash,update_workers=1, spawn_read_thread=False)
client.connect()
另外,如果您對我在Telethon集成中的所有代碼都感興趣,可以在下面的GitHub鏈接中找到它;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.