SAGIRI-kawaii / sagiri-bot

基于Graia Ariadne和Mirai的QQ机器人 SAGIRI-BOT
GNU Affero General Public License v3.0
696 stars 83 forks source link

[Bug Report]群名存在表情符号时会启动失败 #107

Closed BoBppy closed 2 years ago

BoBppy commented 3 years ago

好像是logoru的问题?

nullqwertyuiop commented 3 years ago

尝试把数据库中 setting.group_name 的排序规则改成 uft8mb4_general_ci 试试?

SAGIRI-kawaii commented 3 years ago

尝试使用sqlite(x

nullqwertyuiop commented 3 years ago

尝试使用sqlite(x

(比较惭愧,至今不会用sqlite.jpg

nullqwertyuiop commented 3 years ago

mysql的话,排序规则改成 uft8mb4_general_ci 可以解决大部分问题,除了聊天记录储存 emoji 时会报错

BoBppy commented 3 years ago

@SAGIRI-kawaii 事SQLite啊

nullqwertyuiop commented 3 years ago

多洗爹,感觉这个库好像就我在用MySQL(

SAGIRI-kawaii commented 3 years ago

报错是什么

BoBppy commented 3 years ago

@SAGIRI-kawaii 发你QQ了,这里也发一下

--- Logging error in Loguru Handler #0 ---
2021-08-12 17:47:49.370 | ERROR    | SAGIRIBOT.Core.AppCore:bot_launch_init:174 - Traceback (most recent call last):
  File "D:\Program Files\Python39\lib\site-packages\loguru\_handler.py", line 177, in emit
    self._sink.write(str_record)
  File "D:\Program Files\Python39\lib\site-packages\loguru\_simple_sinks.py", line 26, in write
    self._stream.write(message)
UnicodeEncodeError: 'gbk' codec can't encode character '\U0001f33f' in position 117: illegal multibyte sequence

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Program Files (x86)\mirai\sagiri-bot-2.1.6\SAGIRIBOT\Core\AppCore.py", line 158, in bot_launch_init
    logger.info(f"群ID: {str(result.group_id).ljust(14)}群名: {result.group_name}")
  File "D:\Program Files\Python39\lib\site-packages\loguru\_logger.py", line 1971, in info
    __self._log("INFO", None, False, __self._options, __message, args, kwargs)
  File "D:\Program Files\Python39\lib\site-packages\loguru\_logger.py", line 1959, in _log
    handler.emit(log_record, level_id, from_decorator, raw, colored_message)
  File "D:\Program Files\Python39\lib\site-packages\loguru\_handler.py", line 182, in emit
    self._error_interceptor.print(record)
  File "D:\Program Files\Python39\lib\site-packages\loguru\_error_interceptor.py", line 28, in print
    sys.stderr.write("Record was: %s\n" % record_repr)
UnicodeEncodeError: 'gbk' codec can't encode character '\u2139' in position 291: illegal multibyte sequence

[2021-08-12 17:47:49,380][ERROR]: Error in connection handler
Traceback (most recent call last):
  File "D:\Program Files\Python39\lib\site-packages\loguru\_handler.py", line 177, in emit
    self._sink.write(str_record)
  File "D:\Program Files\Python39\lib\site-packages\loguru\_simple_sinks.py", line 26, in write
    self._stream.write(message)
UnicodeEncodeError: 'gbk' codec can't encode character '\U0001f33f' in position 117: illegal multibyte sequence

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Program Files (x86)\mirai\sagiri-bot-2.1.6\SAGIRIBOT\Core\AppCore.py", line 158, in bot_launch_init
    logger.info(f"群ID: {str(result.group_id).ljust(14)}群名: {result.group_name}")
  File "D:\Program Files\Python39\lib\site-packages\loguru\_logger.py", line 1971, in info
    __self._log("INFO", None, False, __self._options, __message, args, kwargs)
  File "D:\Program Files\Python39\lib\site-packages\loguru\_logger.py", line 1959, in _log
    handler.emit(log_record, level_id, from_decorator, raw, colored_message)
  File "D:\Program Files\Python39\lib\site-packages\loguru\_handler.py", line 182, in emit
    self._error_interceptor.print(record)
  File "D:\Program Files\Python39\lib\site-packages\loguru\_error_interceptor.py", line 28, in print
    sys.stderr.write("Record was: %s\n" % record_repr)
UnicodeEncodeError: 'gbk' codec can't encode character '\u2139' in position 291: illegal multibyte sequence

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Program Files\Python39\lib\site-packages\graia\application\__init__.py", line 1617, in launch_blocking
    loop.run_until_complete(self.getFetching()())
  File "D:\Program Files\Python39\lib\asyncio\base_events.py", line 629, in run_until_complete
    self.run_forever()
  File "D:\Program Files\Python39\lib\asyncio\windows_events.py", line 316, in run_forever
    super().run_forever()
  File "D:\Program Files\Python39\lib\asyncio\base_events.py", line 596, in run_forever
    self._run_once()
  File "D:\Program Files\Python39\lib\asyncio\base_events.py", line 1890, in _run_once
    handle._run()
  File "D:\Program Files\Python39\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "D:\Program Files\Python39\lib\site-packages\graia\broadcast\__init__.py", line 256, in Executor
    return result
  File "D:\Program Files\Python39\lib\site-packages\graia\broadcast\interfaces\dispatcher.py", line 200, in __aexit__
    raise exc.with_traceback(tb)
  File "D:\Program Files\Python39\lib\site-packages\graia\broadcast\__init__.py", line 204, in Executor
    result = await run_always_await_safely(
  File "D:\Program Files\Python39\lib\site-packages\graia\broadcast\utilles.py", line 30, in run_always_await_safely
    return await callable(*args, **kwargs)
  File "D:\Program Files (x86)\mirai\sagiri-bot-2.1.6\main.py", line 60, in init
    await core.bot_launch_init()
  File "D:\Program Files (x86)\mirai\sagiri-bot-2.1.6\SAGIRIBOT\Core\AppCore.py", line 175, in bot_launch_init
    exit()
  File "D:\Program Files\Python39\lib\_sitebuiltins.py", line 26, in __call__
    raise SystemExit(code)
SystemExit: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Program Files\Python39\lib\site-packages\websockets\legacy\protocol.py", line 750, in transfer_data
    message = await self.read_message()
  File "D:\Program Files\Python39\lib\site-packages\websockets\legacy\protocol.py", line 819, in read_message
    frame = await self.read_data_frame(max_size=self.max_size)
  File "D:\Program Files\Python39\lib\site-packages\websockets\legacy\protocol.py", line 895, in read_data_frame
    frame = await self.read_frame(max_size)
  File "D:\Program Files\Python39\lib\site-packages\websockets\legacy\protocol.py", line 971, in read_frame
    frame = await Frame.read(
  File "D:\Program Files\Python39\lib\site-packages\websockets\legacy\framing.py", line 55, in read
    data = await reader(2)
  File "D:\Program Files\Python39\lib\asyncio\streams.py", line 723, in readexactly
    await self._wait_for_data('readexactly')
  File "D:\Program Files\Python39\lib\asyncio\streams.py", line 517, in _wait_for_data
    await self._waiter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\Program Files\Python39\lib\site-packages\websockets\legacy\server.py", line 293, in handler
    await self.ws_handler(self, path)
  File "D:\Program Files (x86)\mirai\sagiri-bot-2.1.6\WebManager\websocket.py", line 19, in log_sender
    await websocket.send(logs[0])
  File "D:\Program Files\Python39\lib\site-packages\websockets\legacy\protocol.py", line 471, in send
    await self.ensure_open()
  File "D:\Program Files\Python39\lib\site-packages\websockets\legacy\protocol.py", line 721, in ensure_open
    raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: code = 1006 (connection closed abnormally [internal]), no reason
[2021-08-12 17:47:49,492][INFO]: application shutdowned.
BoBppy commented 3 years ago

个人猜想gbk换成utf不就好了(