pythontelegrambot如何阅读私人频道帖子(频道中的bot是admin)

2024-04-19 22:37:53 发布

您现在位置:Python中文网/ 问答频道 /正文

from telegram import *
from telegram.ext import *
import requests
import os


def filter(self, update: Update, contex: CallbackContext):
    user_msg = Chat(id=update.effective_chat.id)
    print(user_msg)
    # user_msg = update.message.text
    #
    # text_list = os.linesep.join([s for s in str(user_msg).splitlines() if s])
    # self.post(str(text_list).replace('#', '%23'))

def post(self, text):
    url = f'https://api.telegram.org/bot{self.token}/sendMessage?chat_id={self.destination_id}&text={text}'
    return requests.get(url).status_code == 200

def start(self):
    self.dispatcher.add_handler(MessageHandler(None, self.filter))
    self.updater.start_polling()

我想阅读一个私人频道的文本,但它现在显示文本


Tags: textfromimportselfidosdefchat