“Updater”对象没有属性“dispatcher”错误

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

我正在尝试为选定的用户消息发送电报来不和谐机器人,但无论我做什么,我都会遇到错误:AttributeError:“Updater”对象没有属性“dispatcher”

我在任何地方都找不到调度员的替代者。这是我第一次尝试这个。

这是我当前的代码:

import telegram
from telegram.ext import *
from discord.ext import commands
import discord
import asyncio

telegram_token = ""


discord_token = ""

# Discord Channel ID
discord_channel_id = "112865"


telegram_bot = telegram.Bot(token=telegram_token)


intents = discord.Intents.default()
discord_bot = discord.Client(intents=intents)

def telegram_message_handler(update, context):
    message = update.effective_message
    text = message.text
    username = message.from_user.username
    # Send the message to Discord
    discord_message = f"[@{username}]: {text}"
    discord_channel = discord_bot.get_channel(int(discord_channel_id))
    asyncio.run_coroutine_threadsafe(discord_channel.send(discord_message), discord_bot.loop)


updater = Updater(telegram_token, update_queue=None)
dispatcher = updater.dispatcher
message_handler = MessageHandler(filters.text & ~filters.command, telegram_message_handler)
dispatcher.add_handler(message_handler)

@discord_bot.event
async def on_ready():
    print(f"Connected to Discord as {discord_bot.user.name}")

@discord_bot.event
async def on_message(message):
    if message.author == discord_bot.user:
        return
    # Send the message to Telegram
    telegram_chat_id = "dav52"
    await telegram_bot.send_message(chat_id=telegram_chat_id, text=message.content)

# Start the Telegram bot
updater.start_polling()

# Start the Discord bot
discord_bot.run(discord_token)
python discord telegram telegram-bot
1个回答
-1
投票

同样的错误伙伴。我也收到错误。如果您发现有用的东西,请告诉我。

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