From 401206c8c5b8e8b651d1117d7dc9577f32e915e2 Mon Sep 17 00:00:00 2001 From: PC-Admin Date: Fri, 18 Aug 2023 17:01:24 +0800 Subject: [PATCH] you say defect, i say feature. script won't interactively take variables anymore. fixes #3 --- .gitignore | 3 ++- __pycache__/user_commands.cpython-310.pyc | Bin 13399 -> 0 bytes moderation_tool.py | 27 +++++++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) delete mode 100644 __pycache__/user_commands.cpython-310.pyc diff --git a/.gitignore b/.gitignore index 04a32a3..134b583 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -hardcoded_variables.py \ No newline at end of file +hardcoded_variables.py +__pycache__ \ No newline at end of file diff --git a/__pycache__/user_commands.cpython-310.pyc b/__pycache__/user_commands.cpython-310.pyc deleted file mode 100644 index 39f04a324436c86a05c6fe062baf1c1e44cf30d1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13399 zcmcIrU5p%8R_>~FN2gXFRc!%AcK1>}flMP4KSQb{r>UqfCD6&5sGR%6)4* zJ?`o1+^Y6uT0ICU2`g5ZUBMC%Nx+ss$d4;{;{^#GfF~YNy&%Ms-&pwt4I<_{=T=o$ zch8Jt1Y`BRRk!Y6)ji)i-#Pc%pPI6B`1_lG`DgKqcXGLZr+DH6;tRU|5@%zQJfS7VSc7vu|!c=D47rw!bWb3 zNl`*RDW*gjc}Yx*3i2s2BW978#hjQ&J}nN2gUBmlK`bJl5r@PQ@>%hSIE;Kw91)Kq zpBIk_2l)ZUzD@DT>o~Yk&Wz)Ud@`A{^>IPoDD_c=fdYzWr@Tz)bbpubf-3>3YLbutf zdu?$iCuz}kKB%qv8(yu`aK%QmU3=S;;aX$O4c~LSt#EL=?8|HQcfF1u)Hd8uHa|JB zfq|tPHvRUA(Dz$48lv9tH#Xe12$nlrQMuzvno2x0jTTr)Y^{WUh9*n6d9^{GBKa%g z!o-h1%U|Q7j}LQQms4R*=$~radZ_g|ZyUJEQHjWh`g;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^m(DzZ|A ziF;|hD_00?mIlr3ZhX4heVec@n5RgB7rO!bMP zV*GxCfYYdSEv+JymdI6|PB7M!cRE5+M%s!jA)Q2})Zrj9#s6*69DjkwRqfTPuJ(#Z z#HvS>$Ib4Qg97D>^KmD71Dule8`lxBW1t+P3KuEiV^8nW)q9kDM2Sm@q=e$t9Ile= z;*(d+z7_izl5CJ9)+fm{v%zAerjS6B%)B?_i$iDD_we6Bx-IYfSfX5T8VS8*=AUkx k)?=1qJ!8#TN318U1?ws6AW9A*pFw)inzat&w^*M4AK9YNyZ`_I diff --git a/moderation_tool.py b/moderation_tool.py index c8f8f81..4511f6e 100755 --- a/moderation_tool.py +++ b/moderation_tool.py @@ -1,6 +1,14 @@ + #!/bin/env python3 +import os import json + +# Check if ./hardcoded_variables.py file exists +if not os.path.exists("./hardcoded_variables.py"): + print("ERROR: The file './hardcoded_variables.py' does not exist. It must be configured before using this script.") + exit() + import user_commands import room_commands import server_commands @@ -8,24 +16,31 @@ import ipinfo_commands import rdlist_commands import report_commands import bot_commands + +# Importing the module only after verifying its existence import hardcoded_variables -# check if homeserver url is hard coded, if not set it +# If it does exist... check if the variables are configured: + +# check if homeserver url is the default if hardcoded_variables.homeserver_url == "matrix.example.org": - homeserver_url = input("homeserver_url not configured; What is the URL of your server? Eg: matrix.example.org ") + print("ERROR: homeserver_url not configured, please configure your './hardcoded_variables.py' file!") + exit() -# check if base url is hard coded, if not set it +# check if base url is the default if hardcoded_variables.base_url == "example.org": - base_url = input("base_url not configured; What is the URL of your server? Eg: example.org ") + print("ERROR: base_url not configured, please configure your './hardcoded_variables.py' file!") + exit() -# check if access token is hard coded, if not set it +# check if access token is the default length_access_token = len(hardcoded_variables.access_token) if length_access_token == 0: - access_token = input("access_token not configured; Please enter access token for server admin account: ") + print("ERROR: access_token not configured, please configure your './hardcoded_variables.py' file!") + exit() # loop menu for various moderation actions