diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2020-04-18 11:44:53 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2020-04-18 11:50:58 +0200 |
commit | 00aa14b67e705e4d53397490ee5719a17e8d0d22 (patch) | |
tree | 93add523d2d3cbc4069abbc02d644d7f486f0e4b /wee_slack.py | |
parent | cd4f3ce111075adf60d47e3c3aefd5848d41b47c (diff) | |
download | wee-slack-00aa14b67e705e4d53397490ee5719a17e8d0d22.tar.gz |
Prevent errors after running /upgrade
After running /upgrade, all the buffers will still exist, but the script
is stopped and run again, so all the state in the script will be gone.
This causes a bunch of errors because buffers can't be created and the
script won't know about the existing buffers.
Instead of loading the script normally, print a note that wee-slack will
not work until it's reloaded. I didn't take the effort to make it work
automatically, because it should be easy for users just to reload it.
Fixes #275, fixes #309, fixes #310
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/wee_slack.py b/wee_slack.py index 30b9896..53ff54c 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1187,9 +1187,10 @@ def stop_talking_to_slack(): which triggers leaving the channel because of how close buffer is handled """ - EVENTROUTER.shutdown() - for team in EVENTROUTER.teams.values(): - team.ws.shutdown() + if 'EVENTROUTER' in globals(): + EVENTROUTER.shutdown() + for team in EVENTROUTER.teams.values(): + team.ws.shutdown() return w.WEECHAT_RC_OK ##### New Classes @@ -5218,8 +5219,14 @@ if __name__ == "__main__": SCRIPT_DESC, "script_unloaded", ""): weechat_version = w.info_get("version_number", "") or 0 + weechat_upgrading = w.info_get("weechat_upgrading", "") + if int(weechat_version) < 0x1030000: w.prnt("", "\nERROR: Weechat version 1.3+ is required to use {}.\n\n".format(SCRIPT_NAME)) + elif weechat_upgrading == "1": + w.prnt("", "NOTE: wee-slack will not work after running /upgrade until it's" + " reloaded. Please run `/python reload slack` to continue using it. You" + " will not receive any new messages in wee-slack buffers until doing this.") else: global EVENTROUTER |