Python 试图将不一致消息桥接到电报

Python 试图将不一致消息桥接到电报,python,telegram,discord.py,python-telegram-bot,Python,Telegram,Discord.py,Python Telegram Bot,需要一些帮助,尝试在不和谐频道和电报频道之间建立一座桥梁。我收到了迪斯科公司发来的电报,但我被难倒了。我收到了电报信息,但我不知道如何把它们传给迪斯科 from discord.ext import commands import telegram.ext from telegram.ext import MessageHandler, Filters, Updater telegram_token = 'str' telegram_group = 'str' discord_channel

需要一些帮助,尝试在不和谐频道和电报频道之间建立一座桥梁。我收到了迪斯科公司发来的电报,但我被难倒了。我收到了电报信息,但我不知道如何把它们传给迪斯科

from discord.ext import commands
import telegram.ext
from telegram.ext import MessageHandler, Filters, Updater

telegram_token = 'str'
telegram_group = 'str'
discord_channel = 'int'


class repeater(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_message(self, message):
        homechannel = self.bot.get_channel(discord_channel)
        if message.channel == homechannel:
            Tele_Bot = telegram.Bot(token=telegram_token)
            Tele_Bot.sendMessage(chat_id=telegram_group, text=f'{message.guild.name}:{message.author}:\n{message.content}')
            print('Message Detected from Discord & Sent')


class telegram_repeater(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
    updater = Updater(token=telegram_token, use_context=True)
    dispatcher = updater.dispatcher

    def echo(update, context):
        #The Magic would Happen here.

    echo_handler = MessageHandler(Filters.text, echo)
    dispatcher.add_handler(echo_handler)
    updater.start_polling()


def setup(bot):
    bot.add_cog(repeater(bot))
    bot.add_cog(telegram_repeater(bot))

如何获取discord频道,然后向其发送电报消息?

假设您已导入discord并运行客户端bot:

导入不一致
client=discord.client()
client.run('您的令牌在此')
向特定频道发送消息:

channel=client.get\u channel(discord\u channel\u id)
等待频道。发送消息(您的消息字符串)
链接你应该看看

如果您不想在处理异步到同步时遇到任何大问题,请使用异步电报库。