Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix old token raise unexcepted errors #20

Merged
merged 2 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ matrix_sync:
config_path: Config path
need_edit_config: Please edit the default config.json to the correct configuration information, and then restart the plugin after enabling the plugin_enabled item in settings.json!
read_config: Applying precent config, please waiting...
token_invaild: Please manually delete the old version's token, then reload this plugin!
user_mismatch: Detected token cached mismatch present bot account (%user_id%), please delete token or use correct bot account!
do_unload: Plugin is unloading, please reload manually after you configured right.
on_console:
Expand Down
1 change: 1 addition & 0 deletions lang/zh_cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ matrix_sync:
config_path: 配置文件所在目录
need_edit_config: 请将默认配置config.json修改为正确的配置信息,然后启用settings.json中的plugin_enabled项后重启插件!
read_config: 正在应用当前配置,请稍等……
token_invaild: 请手动删除旧版本的token,然后重载插件!
user_mismatch: 检测到当前配置的机器人账号(%user_id%)与缓存的token不符,请删除当前token.json或使用正确的账号!
do_unload: 插件将卸载,请在处理完成后手动重载插件!
on_console:
Expand Down
4 changes: 4 additions & 0 deletions matrix_sync/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ async def getMsg() -> None:
psi.logger.error(tip.replace("%user_id%", user_id))
psi.logger.info(tr("init_tips.do_unload"))
psi.unload_plugin(plgSelf.id)
else:
psi.logger.error(tr("init_tips.token_invaild"))
psi.logger.info(tr("init_tips.do_unload"))
psi.unload_plugin(plgSelf.id)
else:
client.user_id = user_id
client.device_id = device_id
Expand Down
13 changes: 9 additions & 4 deletions matrix_sync/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ async def sendMsg(message) -> None:
user, token = await getToken()
client.access_token = token
if user != user_id:
tip = tr("init_tips.user_mismatch")
psi.logger.error(tip.replace("%user_id%", user_id))
psi.logger.info(tr("init_tips.do_unload"))
psi.unload_plugin(plgSelf.id)
if user is not None:
tip = tr("init_tips.user_mismatch")
psi.logger.error(tip.replace("%user_id%", user_id))
psi.logger.info(tr("init_tips.do_unload"))
psi.unload_plugin(plgSelf.id)
else:
psi.logger.error(tr("init_tips.token_invaild"))
psi.logger.info(tr("init_tips.do_unload"))
psi.unload_plugin(plgSelf.id)
else:
client.user_id = user_id
client.device_id = device_id
Expand Down
Loading