progval / Limnoria

A robust, full-featured, and user/programmer-friendly Python IRC bot, with many existing plugins.
https://docs.limnoria.net/
Other
621 stars 174 forks source link

Cyrillic config values are being escaped in bot config #1589

Closed ssdaniel24 closed 2 months ago

ssdaniel24 commented 2 months ago

Cyrillic config values that are automatically created using limnoria-wizard with choosen language 'ru' are being recorded as unicode escape sequences. And limnoria can't read them when starting limnoria limnoria.conf. Example:

# limnoria.conf fragment
...
###
# Определяет содержание сообщения, которым бот отвечает в случае
# успешного выполнения команды. Если эта настройка пуста, то сообщение
# не будет отправлено.
###
supybot.replies.success: \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\
                         \u043f\u0440\u043e\u0448\u043b\u0430\
                         \u0443\u0441\u043f\u0435\u0448\u043d\u043e.
...

Error like this:

$ limnoria limnoria.conf
Error unpacking line 'supybot.replies.errorOwner:
\\u041f\\u0440\\u043e\\u0438\\u0437\\u043e\\u0448\\u043b ...' in limnoria.conf.
Please fix this error and start supybot again.
Traceback (most recent call last):
  File "/home/limnoria/env/lib/python3.11/site-packages/supybot/registry.py", line 110, in open_registry
    value = decoder(value)[0]
            ^^^^^^^^^^^^^^
UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 269-271: truncated \uXXXX escape
progval commented 2 months ago

Could you show me the supybot.replies.errorOwner config block you had when you got this error?

ssdaniel24 commented 2 months ago

Block:

###
# Определяет, какое сообщение об ошибке бот выдает владельцу, если оно
# неоднозначное.
###
supybot.replies.errorOwner: \u041f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\
                            \u0430 \u043e\u0448\u0438\u0431\u043a\u0430,\
                            \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u0430\
                            \u0432 \u0436\u0443\u0440\u043d\u0430\u043b. \u0\
                            41f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0\
                            435 \u0435\u0433\u043e \u0434\u043b\u044f \u0434\
                            \u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\
                            \u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u044\
                            4\u043e\u0440\u043c\u0430\u0446\u0438\u0438.

Error:

$ limnoria lala.conf
Error unpacking line 'supybot.replies.errorOwner:
\\u041f\\u0440\\u043e\\u0438\\u0437\\u043e\\u0448\\u043b
\\u0430 \\u043e\\u0448\\u0438\\u0431\\u043a\\u0430,
\\u0437\\u0430\\u043f\\u0438\\u0441\\u0430\\u043d\\u0430
\\u0432 \\u0436\\u0443\\u0440\\u043d\\u0430\\u043b. \\u0
41f\\u0440\\u043e\\u0432\\u0435\\u0440\\u044c\\u0442\\u0
435 \\u0435\\u0433\\u043e \\u0434\\u043b\\u044f \\u0434
\\u043e\\u043f\\u043e\\u043b\\u043d\\u0438\\u0442\\u0435
\\u043b\\u044c\\u043d\\u043e\\u0439 \\u0438\\u043d\\u044
4\\u043e\\u0440\\u043c\\u0430\\u0446\\u0438\\u0438.' in lala.conf.
Please fix this error and start supybot again.
Traceback (most recent call last):
  File "/home/limnoria/env/lib/python3.11/site-packages/supybot/registry.py", line 110, in open_registry
    value = decoder(value)[0]
            ^^^^^^^^^^^^^^
UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 269-271: truncated \uXXXX escape

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/limnoria/env/bin/limnoria", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/limnoria/env/lib/python3.11/site-packages/supybot/scripts/limnoria.py", line 208, in main
    registry.open_registry(registryFilename)
  File "/home/limnoria/env/lib/python3.11/site-packages/supybot/registry.py", line 113, in open_registry
    raise InvalidRegistryFile('Error unpacking line %r' % acc)
supybot.registry.InvalidRegistryFile: Error unpacking line 'supybot.replies.errorOwner: \\u041f\\u0440\\u043e\\u0438\\u0437\\u043e\\u0448\\u043b                            \\u0430 \\u043e\\u0448\\u0438\\u0431\\u043a\\u0430,                            \\u0437\\u0430\\u043f\\u0438\\u0441\\u0430\\u043d\\u0430                            \\u0432 \\u0436\\u0443\\u0440\\u043d\\u0430\\u043b. \\u0                            41f\\u0440\\u043e\\u0432\\u0435\\u0440\\u044c\\u0442\\u0                            435 \\u0435\\u0433\\u043e \\u0434\\u043b\\u044f \\u0434                            \\u043e\\u043f\\u043e\\u043b\\u043d\\u0438\\u0442\\u0435                            \\u043b\\u044c\\u043d\\u043e\\u0439 \\u0438\\u043d\\u044                            4\\u043e\\u0440\\u043c\\u0430\\u0446\\u0438\\u0438.'
progval commented 2 months ago

Sorry, you need to manually fix your config file. Could you install #1590, then check the bot no longer corrupts your config file on shutdown?