Skip to content

Commit

Permalink
Merge pull request #20 from Mooling0602/dev
Browse files Browse the repository at this point in the history
Fix old token raise unexcepted errors
  • Loading branch information
Mooling0602 authored Dec 15, 2024
2 parents e2e3dc6 + fd86d8d commit d7ea587
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
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

0 comments on commit d7ea587

Please sign in to comment.