-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e40b138
commit 992bcb4
Showing
5 changed files
with
81 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from importlib import reload | ||
|
||
from redbot.core.bot import Red | ||
from redbot.core.errors import CogLoadError | ||
|
||
|
||
async def validate_tagscriptengine(bot: Red, tse_version: str, *, reloaded: bool = False): | ||
try: | ||
import TagScriptEngine as tse | ||
except ImportError as exc: | ||
raise CogLoadError( | ||
"The ThreadOpener cog failed to install TagScriptEngine. Reinstall the cog and restart your " | ||
"bot. If it continues to fail to load, contact the cog author." | ||
) from exc | ||
|
||
commands = [ | ||
"`pip(3) uninstall -y TagScriptEngine`", | ||
"`pip(3) uninstall -y TagScript`", | ||
f"`pip(3) install TagScript=={tse_version}`", | ||
] | ||
commands = "\n".join(commands) | ||
|
||
message = ( | ||
"The ThreadOpener cog attempted to install TagScriptEngine, but the version installed " | ||
"is outdated. Shut down your bot, then in shell in your venv, run the following " | ||
f"commands:\n{commands}\nAfter running these commands, restart your bot and reload " | ||
"Tags. If it continues to fail to load, contact the cog author." | ||
) | ||
|
||
if not hasattr(tse, "VersionInfo"): | ||
if not reloaded: | ||
reload(tse) | ||
await validate_tagscriptengine(bot, tse_version, reloaded=True) | ||
return | ||
|
||
await bot.send_to_owners(message) | ||
raise CogLoadError(message) | ||
|
||
if tse.version_info < tse.VersionInfo.from_str(tse_version): | ||
await bot.send_to_owners(message) | ||
raise CogLoadError(message) |