diff --git a/.vscode/launch.json b/.vscode/launch.json index 49b8c3c..caf01ae 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,7 +8,10 @@ "module": "r0c", "console": "integratedTerminal", "cwd": "${workspaceFolder}", - "args": [] + "args": [ + //"--hex-rx", + //"--hex-tx" + ] } ] } \ No newline at end of file diff --git a/r0c/__main__.py b/r0c/__main__.py index 24514a9..27139ba 100644 --- a/r0c/__main__.py +++ b/r0c/__main__.py @@ -224,7 +224,6 @@ printf '%s\\n' GK . . . . r0c.int . | openssl req -newkey rsa:2048 -sha256 -keyo print("\033[0m") print(" * Logs at " + EP.log) - Util.compat_chans_in_root() self.stopping = 0 self.threadmon = False @@ -353,7 +352,7 @@ printf '%s\\n' GK . . . . r0c.int . | openssl req -newkey rsa:2048 -sha256 -keyo fast = {} for srv in self.servers: for c in srv.clients: - if c.slowmo_tx or c.wizard_stage is not None: + if c.slowmo_tx or (c.wizard_stage is not None and not c.is_bot): slow[c.socket] = c else: fast[c.socket] = c diff --git a/r0c/__version__.py b/r0c/__version__.py index c69a596..ef3e36d 100644 --- a/r0c/__version__.py +++ b/r0c/__version__.py @@ -1,5 +1,5 @@ -VERSION = (1, 3, 1) -BUILD_DT = (2022, 7, 4) +VERSION = (1, 3, 2) +BUILD_DT = (2022, 9, 1) S_VERSION = u".".join(map(str, VERSION)) S_BUILD_DT = u"{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT) diff --git a/r0c/diag.py b/r0c/diag.py index 7f98227..b29d79e 100644 --- a/r0c/diag.py +++ b/r0c/diag.py @@ -27,6 +27,8 @@ def memory_dump(): ) +""" + def get_obj_name(target_id): variables = {} variables.extend(locals()) @@ -60,6 +62,8 @@ def find_leaked_messages(): print("ref:", ref_objs) print() +""" + # repl notepad """ diff --git a/r0c/ivt100.py b/r0c/ivt100.py index 2c78683..3a31566 100644 --- a/r0c/ivt100.py +++ b/r0c/ivt100.py @@ -821,7 +821,6 @@ class VT100_Client(object): else: # always clear and resend the status bar for non-vt100 - to_send += u"\r" + (u" " * 78) + u"\r" to_send += self.update_status_bar(True) # handle keyboard strokes from non-linemode clients, @@ -954,7 +953,7 @@ class VT100_Client(object): len(nchan.msgs) - uchan.vis[-1].im ) - if nchan.name: + if nchan.name and self.vt100: online = u"\033[22;36m {0}".format(nchan.usernames) else: online = u"" @@ -975,17 +974,10 @@ class VT100_Client(object): )[0] if not self.vt100: - now = int(time.time()) - ret = u"" - if ( - full_redraw - or (now % 5 == 1) - or ((hilights or activity) and now % 2 == 1) - ): - ret = u"\r{0} {1}> ".format(Util.strip_ansi(line), self.user.nick) - self.left_chrome = ret - - return ret + self.left_chrome = u"{0} {1}> ".format( + Util.strip_ansi(line), self.user.nick + ) + return u"\r{0}\r{1}".format(u" " * 78, self.left_chrome) elif full_redraw: if self.screen[self.h - (self.y_status + 1)] != line: @@ -1810,6 +1802,7 @@ class VT100_Client(object): if self.host.re_bot.search(self.in_text_full): self.wizard_stage = "bot1" self.is_bot = True + self.world.cserial += 1 m = "{0} {1}".format(self.user.nick, self.adr[0]) self.host.schedule_kick(self, 69, " botkick: " + m) @@ -2074,6 +2067,7 @@ class VT100_Client(object): # cheatcode: windows telnet + join elif self.in_text.startswith("wtn"): + self.slowmo_tx = 1 self.set_codec("cp437") self.wizard_stage = "end" join_ch = self.in_text[3:] diff --git a/r0c/user.py b/r0c/user.py index 2e3e2d0..eac88fb 100644 --- a/r0c/user.py +++ b/r0c/user.py @@ -1,7 +1,7 @@ # coding: utf-8 from __future__ import print_function from .__version__ import S_VERSION, S_BUILD_DT -from .__init__ import EP, PY2 +from .__init__ import EP, PY2, TYPE_CHECKING from . import util as Util from . import chat as Chat from . import diag as Diag @@ -16,6 +16,9 @@ from datetime import datetime import code import gc +if TYPE_CHECKING: + from . import world as World + print = Util.print @@ -61,6 +64,7 @@ if your terminal is tiny, try \033[36m/mn\033[0m and \033[36m/cy\033[0m class User(object): def __init__(self, world, address): + # type: (World.World, tuple[str, int]) -> User self.ar = world.ar self.world = world self.admin = False # set true after challenge success diff --git a/r0c/util.py b/r0c/util.py index 91894d5..ed4a790 100644 --- a/r0c/util.py +++ b/r0c/util.py @@ -124,6 +124,8 @@ def hexdump(pk, prefix="", file=None): ascstr += " " +""" + def test_hexdump(): try: from StringIO import StringIO as bio @@ -147,6 +149,8 @@ def test_hexdump(): sys.exit(0) +""" + def trunc(txt, maxlen): eoc = azAZ @@ -465,6 +469,8 @@ def b35dec(b35str): return factor * ret +""" + def visualize_all_unicode_codepoints_as_utf8(): stats = [0] * 256 nmax = sys.maxunicode + 1 @@ -509,6 +515,8 @@ def visualize_all_unicode_codepoints_as_utf8(): # visualize_all_unicode_codepoints_as_utf8() +""" + def wrap(txt, maxlen, maxlen2): words = txt.rstrip().split() @@ -603,34 +611,6 @@ def host_os(): return "{0} on {1}{2}".format(py_ver, host_os, bitness) -def compat_chans_in_root(): - bad_dirs = [] - good_dirs = ["pm", "chan", "wire"] - for (dirpath, dirnames, filenames) in os.walk(EP.log): - for d in dirnames: - if d not in good_dirs: - bad_dirs.append(d) - break - - if bad_dirs: - print() - print("== performing upgrade in 5 seconds ==") - print() - print("Will move the following directories from [log] to [log/chan]:") - print(", ".join(bad_dirs)) - print() - print("PRESS CTRL-C TO ABORT") - for n in range(5): - print("{0} ...".format(5 - n)) - time.sleep(1) - - for d in bad_dirs: - os.rename("{0}{1}".format(EP.log, d), "{0}chan/{1}".format(EP.log, d)) - - print("upgrade done \\o/") - print() - - def py26_threading_event_wait(event): """ threading.Event.wait() is broken on py2.6; diff --git a/r0c/world.py b/r0c/world.py index 3b1cd30..03f14bd 100644 --- a/r0c/world.py +++ b/r0c/world.py @@ -205,11 +205,8 @@ class World(object): nchan.log_ctr += 1 nchan.log_fh.write( - ( - u" ".join( - [hex(int(msg.ts * 8.0))[2:].rstrip("L"), msg.user, msg.txt] - ) - + u"\n" + u"{0} {1} {2}\n".format( + hex(int(msg.ts * 8.0))[2:].rstrip("L"), msg.user, msg.txt ).encode("utf-8") ) @@ -300,6 +297,7 @@ class World(object): uchan.alias = alias return uchan + """ def broadcast_banner(self, msg): with self.mutex: chans = {} @@ -330,6 +328,7 @@ class World(object): user.client.say( to_send.encode(user.client.codec, "backslashreplace") ) + """ def broadcast_message(self, msg, severity=1): """1=append, 2=append+scroll""" @@ -377,8 +376,14 @@ class World(object): user.new_active_chan = user.chans[i] if not quiet: + suf = u"" + if not nchan.name: + suf = u"; reinvite by typing another msg here" + self.send_chan_msg( - u"--", nchan, u"\033[1;33m{0}\033[22m has left".format(user.nick) + u"--", + nchan, + u"\033[1;33m{0}\033[22m has left{1}".format(user.nick, suf), ) if not nchan.uchans: @@ -528,7 +533,7 @@ class World(object): nchan.log_fh.write( u"{0} {1} {2}\n".format( hex(int(msg.ts * 8.0))[2:].rstrip("L"), msg.user, msg.txt - ) + ).encode("utf-8") ) # potential chance that a render goes through diff --git a/scripts/sfx.py b/scripts/sfx.py index a56e186..d81db1a 100644 --- a/scripts/sfx.py +++ b/scripts/sfx.py @@ -404,7 +404,6 @@ def run(tmp): def main(): sysver = str(sys.version).replace("\n", "\n" + " " * 18) pktime = time.strftime("%Y-%m-%d, %H:%M:%S", time.gmtime(STAMP)) - os.system("rem") # best girl msg() msg(" this is: PKG_NAME", VER) msg(" packed at:", pktime, "UTC,", STAMP)