如何修复 loop=asyncio.get.event.loop() deprication 警告

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

我是 python 的新手并尝试运行它但是它在事件循环中显示 deprication 警告我不知道这个循环在哪里以及如何工作请告诉我正确的方法

import asyncio
import importlib
import sys

from pyrogram import idle
from pytgcalls.exceptions import NoActiveGroupCall

import config
from config import BANNED_USERS
from Music import LOGGER, app, userbot
from Music.core.call import Music
from Music.plugins import ALL_MODULES
from Music.utils.database import get_banned_users, get_gbanned

#loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()


async def init():
    if (
        not config.STRING1
        and not config.STRING2
        and not config.STRING3
        and not config.STRING4
        and not config.STRING5
    ):
        LOGGER("Music").error("Add Pyrogram string session and then try...")
    try:
        users = await get_gbanned()
        for user_id in users:
            BANNED_USERS.add(user_id)
        users = await get_banned_users()
        for user_id in users:
            BANNED_USERS.add(user_id)
    except:
        pass
    await app.start()
    for all_module in ALL_MODULES:
        importlib.import_module("Music.plugins" + all_module)
    LOGGER("Music.plugins").info("Necessary Modules Imported Successfully.")
    await userbot.start()
    await Music.start()
    try:
        await Music.stream_call("https://te.legra.ph/file/29f784eb49d230ab62e9e.mp4")
    except NoActiveGroupCall:
        LOGGER("Music").error(
            "[ERROR] - \n\nTurn on group voice chat and don't put it off otherwise I'll stop working thanks."
        )
        sys.exit()
    except:
        pass
    await Music.decorators()
    LOGGER("Music").info("Music Bot Started Successfully")
    await idle()


if __name__ == "__main__":
    loop.run_until_complete(init())
    LOGGER("Music").info("Stopping Music Bot")

我试图将 loop = asyncio.new_event_loop() 替换为旧的,但代码停止响应

python python-telegram-bot event-loop
© www.soinside.com 2019 - 2024. All rights reserved.