python-telegram-bot 没有足够的权限向聊天发送文本

问题描述 投票:0回答:2

机器人工作得很好,突然出现错误,说没有足够的权限来发送文本,所以我检查了频道上的管理员权限,一切都像以前一样,工作时,在频道上尝试了一些更改但似乎没有任何作用。

import asyncio
from telegram.constants import ParseMode
from datetime import datetime, timedelta
import pytz
import random
from telegram import InlineKeyboardMarkup, InlineKeyboardButton

TOKEN = "MY_TOKEN"
chat_id = "MY_CHAT_ID"
image_url = "IMAGE_URL"

async def send_message(bot):
    try:
        now = datetime.now(pytz.timezone('America/Sao_Paulo'))
        later = (now + timedelta(minutes=5)).strftime("%H:%M")

        possibilidade = random.uniform(86, 100)

        keyboard = [
            [InlineKeyboardButton("Inline_Action")]
        ]

        reply_markup = InlineKeyboardMarkup(keyboard)

        message = f"""

        """

        # Await the send_photo coroutine
        await bot.send_photo(chat_id=chat_id, photo=image_url, caption=message, parse_mode=ParseMode.HTML, reply_markup=reply_markup)
    except Exception as e:
        print(f"An error occurred while sending the message: {e}")

async def main():
    bot = telegram.Bot(TOKEN)
    while True:
        await send_message(bot)
        await asyncio.sleep(50)

if __name__ == "__main__":
    asyncio.run(main())

这是我的代码,我在pythonanyware平台上运行,已经尝试了很多东西,也许只有jezus可以帮助我。

已经尝试更改为仅发送文本而不发送照片,在其他频道上尝试了具有其他权限的新机器人,尝试在我的电脑上运行代码,尝试了一种没有库和简单文本的更简单的代码,更新了 python-bot 和也降级了

我需要每 5 分钟在同一频道上发送此消息。

python telegram python-telegram-bot pytz
2个回答
0
投票

我想这可能是一个BUG。因为我的机器人正在工作,但现在给出了这个错误


0
投票

我有同样的错误,我认为这是一个错误

© www.soinside.com 2019 - 2024. All rights reserved.