KarisAya / nonebot_plugin_mcqq_server

mcqq服主版,采用本地读取log信息的方法的Minecraft Server互通消息的插件
MIT License
6 stars 2 forks source link

异步问题 #3

Open LittleChest opened 1 year ago

LittleChest commented 1 year ago
mcr = asyncio.run(mcrcon_connect("127.0.0.1", mcrcon_password, mcrcon_port))

这一行似乎会导致NoneBot崩溃

RuntimeError: There is no current event loop in thread 'MainThread'.

然后我搜了一下应该创建一个新线程再运行

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(mcrcon_connect("127.0.0.1", mcrcon_password, mcrcon_port))

async def mcrcon_connect(host: str, password: str, port: int = 25575):
    mcr = await mcrcon_connect("127.0.0.1", mcrcon_password, mcrcon_port)

(我是小白,还请多多指教)

KarisAya commented 1 year ago

调整了代码结构,这个函数已经用不到了。

LittleChest commented 1 year ago

ImportError: cannot import name 'group_list'

KarisAya commented 1 year ago

ImportError: cannot import name 'group_list'

看看完整的报错

LittleChest commented 1 year ago

ImportError: cannot import name 'group_list'

看看完整的报错

我没更新config.py 抱歉

LittleChest commented 1 year ago

还有个问题就是重构后即使RCON连接失败也不提示 只显示MC_TO_QQ已开启就没了

KarisAya commented 1 year ago

MC_TO_QQ不依靠RCON,依靠RCON的是QQ_TO_MC QQ_TO_MC在首次通信时开始连接

KarisAya commented 1 year ago

MC_TO_QQ不依靠RCON,依靠RCON的是QQ_TO_MC QQ_TO_MC在首次通信时开始连接

群里要接收到一条信息才开始连接

LittleChest commented 1 year ago

MC_TO_QQ不依靠RCON,依靠RCON的是QQ_TO_MC QQ_TO_MC在首次通信时开始连接

我试了一下先开Minecraft服务器再开机器人 也不会连接

LittleChest commented 1 year ago

MC_TO_QQ不依靠RCON,依靠RCON的是QQ_TO_MC QQ_TO_MC在首次通信时开始连接

群里要接收到一条信息才开始连接

了解了

LittleChest commented 1 year ago

MC_TO_QQ不依靠RCON,依靠RCON的是QQ_TO_MC QQ_TO_MC在首次通信时开始连接

群里要接收到一条信息才开始连接

06-30 01:32:37 [ERROR] nonebot | Running Matcher(type='message', module=plugins.nonebot_plugin_mcqq_server) failed.
Traceback (most recent call last):
File "<string>", line 15, in <module>
File "C:\Users\LittleChest\AppData\Local\Programs\Python\Lib\site-packages\nonebot\__init__.py", line 309, in run
get_driver().run(*args, **kwargs)
File "C:\Users\LittleChest\AppData\Local\Programs\Python\Lib\site-packages\nonebot\drivers\none.py", line 71, in run
loop.run_until_complete(self._serve())
File "C:\Users\LittleChest\AppData\Local\Programs\Python\Lib\asyncio\base_events.py", line 640, in run_until_complete
self.run_forever()
File "C:\Users\LittleChest\AppData\Local\Programs\Python\Lib\asyncio\windows_events.py", line 321, in run_forever
super().run_forever()
File "C:\Users\LittleChest\AppData\Local\Programs\Python\Lib\asyncio\base_events.py", line 607, in run_forever
self._run_once()
File "C:\Users\LittleChest\AppData\Local\Programs\Python\Lib\asyncio\base_events.py", line 1922, in _run_once
handle._run()
File "C:\Users\LittleChest\AppData\Local\Programs\Python\Lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "C:\Users\LittleChest\AppData\Local\Programs\Python\Lib\site-packages\nonebot\message.py", line 467, in check_and_run_matcher
await _run_matcher(
File "C:\Users\LittleChest\AppData\Local\Programs\Python\Lib\site-packages\nonebot\message.py", line 419, in _run_matcher
await matcher.run(bot, event, state, stack, dependency_cache)
File "C:\Users\LittleChest\AppData\Local\Programs\Python\Lib\site-packages\nonebot\internal\matcher\matcher.py", line 753, in run
await self.simple_run(bot, event, state, stack, dependency_cache)
File "C:\Users\LittleChest\AppData\Local\Programs\Python\Lib\site-packages\nonebot\internal\matcher\matcher.py", line 728, in simple_run
await handler(
File "C:\Users\LittleChest\AppData\Local\Programs\Python\Lib\site-packages\nonebot\dependencies\__init__.py", line 108, in __call__
return await cast(Callable[..., Awaitable[R]], self.call)(**values)
File "C:\Users\LittleChest\OneDrive\桌面\Bot\plugins\nonebot_plugin_mcqq_server\__init__.py", line 88, in QQ_TO_MC
mcr.command(mc_translate(event))
File "C:\Users\LittleChest\AppData\Local\Programs\Python\Lib\site-packages\mcrcon.py", line 129, in command
result = self._send(2, command)
File "C:\Users\LittleChest\AppData\Local\Programs\Python\Lib\site-packages\mcrcon.py", line 97, in _send
raise MCRconException("Must connect before sending data")
mcrcon.MCRconException: Must connect before sending data