def maybe_start_testing(): hub_name = vh.GetConfig("config", "hub_name") if hub_name == special_hub_name: ver = vh.__version__ if ver[0] == 1 and (ver[1] > 2 or ver[1] == 2 and ver[2] > 3): tester.start_testing(my_test) else: print("ERROR: Cannot run VH Integration Test. Expected version <2.0.0 and >1.2.3, but got %s" % str(ver)) sys.stdout.flush() vh.StopHub(1)
+reladdas <nick> <category> <release> : Add release as <nick> +relimport <category> : Imports a list of releases. <release_1> : (release name cannot contain spaces) <release_2> ... +reldelete <release_idno> : Deletes a release. For users: +relhelp : Show this help +rel all : Show all releases +rel <category> : Show releases for particular category List of categories (case-insensitive): """.replace("%[HUB]", vh.GetConfig("config", "hub_name")) for cat in categories: help += endl + cat[0] help += """ Anyone interested can view the source here: https://github.com/srijan/Verlihub-Releases-Bot ================================================================ """ def OnUserCommand(nick, data): global categories if data == "+rel" or data == "+relhelp": vh.usermc(help, nick) return 0
def my_test(): global tester t = tester if not t.test_is_active: return t.test("It's now %s. Hub has been running for %s seconds" % (datetime.now(), int(time.time() - vh.starttime))) t.test("Script: %s (%s), Python plugin ver. %s / %s" % (vh.name, vh.path, vh.__version__, vh.__version_string__)) t1 = t.test("Checking vh.botname and vh.opchatname values", vh.botname == "Verlihub" and vh.opchatname == "OpChat", "They are: '%s' and '%s'" % (vh.botname, vh.opchatname)) t2 = t.test_eq("Confirming that hublist_host is empty", vh.GetConfig("config", "hublist_host"), "") t3 = t.test_eq("Confirming that send_crash_report is 0", vh.GetConfig("config", "send_crash_report"), "0") t4 = t.test_eq("Checking usercount", vh.GetUsersCount(), 0) if not (t1 and t2 and t3 and t4): t.test("Cannot continue testing with these errors", 0) return t.finish_testing(1) t.test("Trying to set vh.name_and_version", vh.name_and_version(my_name, my_version)) x = vh.name_and_version() t.test("Reading and verifying vh.name_and_version", x and x[0] == my_name and x[1] == my_version, x) t.test("Checking nicklists...") x = vh.GetRawNickList() t.test("Checking vh.GetRawNickList", "Verlihub$$" in x and "OpChat$$" in x and x.startswith("$NickList "), x) x = vh.GetRawOpList() t.test("Checking vh.GetRawOpList", "Verlihub$$" in x and "OpChat$$" in x and x.startswith("$OpList "), x) x = vh.GetRawBotList() t.test("Checking vh.GetRawBotList", "Verlihub$$" in x and "OpChat$$" in x and x.startswith("$BotList "), x) x = vh.GetNickList() t.test("Checking vh.GetNickList", "Verlihub" in x and "OpChat" in x and isinstance(x, list), x) x = vh.GetOpList() t.test("Checking vh.GetOpList", "Verlihub" in x and "OpChat" in x and isinstance(x, list), x) x = vh.GetBotList() t.test("Checking vh.GetBotList", "Verlihub" in x and "OpChat" in x and isinstance(x, list), x) t.test("") t.test("Testing vh.ScriptQuery and communication between scripts...") x = vh.ScriptQuery("_get_script_file", "") t.test("Getting a list of scripts", x and isinstance(x, list), "List is empty. Impossible!") t.test_in("Confirming that we are on it", vh.path, x) t.test("There are %s scripts on the list" % len(x)) x = vh.ScriptQuery("_get_script_file", "", "python") if t.test("Getting a list of python scripts", x and isinstance(x, list), "List is empty. Impossible!"): py_len = len(x) if t.test_in("Confirming that we are on it", vh.path, x): my_pos = x.index(vh.path) t.test("The paths are: %s" % x) x = vh.ScriptQuery("_get_script_name", "", "python", True) if t.test("Getting a list of python script names", x and isinstance(x, list), "Got '%s'" % x): if t.test_eq("Confirming that results in long form have two elements", len(x[0]), 2): t.test("The names are: %s" % [a[0] for a in x]) t.test("Checking our entry", x[my_pos][0] == my_name and x[my_pos][1] == vh.path, x) x = vh.ScriptQuery("_get_script_version", "", "", True) if t.test("Getting a list of python script versions", x and isinstance(x, list), "Got '%s'" % x): if t.test_eq("Confirming that results in long form have two elements", len(x[0]), 2): t.test("The versions are: %s" % [a[0] for a in x]) t.test("Checking our entry", x[my_pos][0] == my_version and x[my_pos][1] == vh.path, x) else: t.test("Aborting this branch", False) else: t.test("Aborting this branch", False) x = vh.ScriptQuery("_get_script_file", "", vh.path) t.test_eq("Asking for our path directly", x, [vh.path]) x = vh.ScriptQuery("_get_script_name", "", vh.path) t.test_eq("Asking for our name directly", x, [my_name]) x = vh.ScriptQuery("_get_script_version", "", vh.path) t.test_eq("Asking for our version directly", x, [my_version]) t.test("") t.test("Testing vh.ScriptQuery and vh.ScriptCommand for communication with scripts...") scripts = vh.ScriptQuery("_get_script_name", "", "python", True) for entry in scripts: if entry[0] == event_logger_name: script = entry[1] t.test("Found %s in %s" % (event_logger_name, script)) if t.test_eq("Turning on logging", vh.ScriptQuery(event_logger_cmd, "1", script), ["is_on"]): t.test("Now you should start seeing output from %s" % event_logger_name) t.test_eq("Confirming that logging is active", vh.ScriptQuery(event_logger_cmd, "", script), ["is_on"]) t.test_eq("Calling logger with sh2p43g cmd", vh.ScriptQuery("sh2p43g", "data", script), []) t.test_eq("Calling python with jm5f03c cmd", vh.ScriptQuery("jm5f03c", "data", "python"), []) t.test_eq("Calling all with pf6j76q cmd", vh.ScriptQuery("pf6j76q", "data"), []) t.test("Using ScriptCommand('wn3f98g', 'data')", vh.ScriptCommand("wn3f98g", "data")) t.test_eq("Turning off logging", vh.ScriptQuery(event_logger_cmd, "0", script), ["is_off"]) return t.finish_testing(0)
def OnOperatorDrops(op, nick): if log(): print "%-45s" % "OnOperatorDrops (op, nick)", (op, nick); sys.stdout.flush() def OnOperatorDropsWithReason(op, nick, reason): if log(): print "%-45s" % "OnOperatorDropsWithReason (op, nick, reason)", (op, nick, reason); sys.stdout.flush() def OnNewReg(op, nick, uclass): if log(): print "%-45s" % "OnNewReg (op, nick, uclass)", (op, nick, uclass); sys.stdout.flush() def OnSetConfig(nick, conf, var, new_val, old_val, val_type): if log(): print "%-45s" % "OnSetConfig (nick, conf, var, new_val, old_val, val_type)", (nick, conf, var, new_val, old_val, val_type); sys.stdout.flush() def OnNewBan(op, ip, nick, reason): if log(): print "%-45s" % "OnNewBan (op, ip, nick, reason)", (op, ip, nick, reason); sys.stdout.flush() #def OnTimer(msecs=None): # if log(): print "%-45s" % "OnTimer(%s)" % msecs; sys.stdout.flush() # def UnLoad(): # global _log # vh.SetConfig("pi_python", "callback_log", str(_log)) #vh.classmc("Script vh_event_log.py is online. To start logging, write !vh_event_log 1, and to stop, !vh_event_log 0", 5, 10) try: _log = int(vh.GetConfig("pi_python", "callback_log")) except: pass