From 11a9904f9d9fa3bc2027dabf4a08ecc37b15fd49 Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Thu, 28 Apr 2022 02:37:27 +0300 Subject: [PATCH] Add support for msg_ghost and xMS (denied chat message packet) --- server/area.py | 6 +++ server/network/aoprotocol.py | 71 +++++++++++++++++++++++++++++++++++- server/tsuserver.py | 1 + 3 files changed, 77 insertions(+), 1 deletion(-) diff --git a/server/area.py b/server/area.py index da0f50e3..4d43688f 100644 --- a/server/area.py +++ b/server/area.py @@ -882,6 +882,8 @@ def send_ic(self, client, *args, targets=None): client.send_ooc( f"Something went wrong, couldn't amend Statement {idx+1}!" ) + # Deny the MS + self.client.send_command("xMS") return adding = args[4].strip( ) != "" and self.recording and client is not None @@ -889,6 +891,8 @@ def send_ic(self, client, *args, targets=None): if len(self.testimony) >= 30: client.send_ooc( "Maximum testimony statement amount reached! (30)") + # Deny the MS + self.client.send_command("xMS") return adding = True else: @@ -940,6 +944,8 @@ def send_ic(self, client, *args, targets=None): "Interjection minigame - target not found!") except Exception as ex: client.send_ooc(ex) + # Deny the MS + self.client.send_command("xMS") return # DRO 1.0.0 client compatibility, tell the client we acknowledged their MS packet diff --git a/server/network/aoprotocol.py b/server/network/aoprotocol.py index 9792dc96..2b7f1872 100644 --- a/server/network/aoprotocol.py +++ b/server/network/aoprotocol.py @@ -358,9 +358,13 @@ def net_cmd_ms(self, args): """ if not self.client.is_checked: + # Deny the MS + self.client.send_command("xMS") return if self.client.is_muted: # Checks to see if the client has been muted by a mod self.client.send_ooc("You are muted by a moderator.") + # Deny the MS + self.client.send_command("xMS") return showname = "" @@ -565,8 +569,12 @@ def net_cmd_ms(self, args): except ValueError: self.client.send_ooc( "Something went wrong! Please report the issue to the developers.") + # Deny the MS + self.client.send_command("xMS") return else: + # Deny the MS + self.client.send_command("xMS") return # Targets for whispering @@ -580,8 +588,12 @@ def net_cmd_ms(self, args): self.client.send_ooc( "This is a muted area - ask the CM to be included in the invite list." ) - return False + # Deny the MS + self.client.send_command("xMS") + return if button == "0" and not self.client.area.can_send_message(self.client): + # Deny the MS + self.client.send_command("xMS") return if ( @@ -592,15 +604,21 @@ def net_cmd_ms(self, args): ): self.client.send_ooc( "Showname changes are forbidden in this area!") + # Deny the MS + self.client.send_command("xMS") return if self.client.area.is_iniswap(self.client, pre, anim, folder, sfx): self.client.send_ooc( f"Iniswap/custom emotes are blocked in this area for character {folder}, pre {pre} anim {anim}." ) + # Deny the MS + self.client.send_command("xMS") return if len(self.client.charcurse) > 0 and folder != self.client.char_name: self.client.send_ooc( "You may not iniswap while you are charcursed!") + # Deny the MS + self.client.send_command("xMS") return if ( not self.client.area.blankposting_allowed @@ -609,6 +627,8 @@ def net_cmd_ms(self, args): ): if text.strip() == "": self.client.send_ooc("Blankposting is forbidden in this area!") + # Deny the MS + self.client.send_command("xMS") return # Regex is slow as hell, need to change this to be more performant if ( @@ -619,11 +639,15 @@ def net_cmd_ms(self, args): self.client.send_ooc( "While that is not a blankpost, it is still pretty spammy. Try forming sentences." ) + # Deny the MS + self.client.send_command("xMS") return if text.replace(" ", "").startswith("(("): self.client.send_ooc( "Please, *please* use the OOC chat instead of polluting IC. Normal OOC is local to area. You can use /g to talk across the entire server." ) + # Deny the MS + self.client.send_command("xMS") return # Scrub text and showname for bad words if ( @@ -667,6 +691,8 @@ def net_cmd_ms(self, args): target_area.append(area) else: self.client.send_ooc(f"You don't own {area.name}!") + # Deny the MS + self.client.send_command("xMS") return if len(target_area) <= 0: for a in self.client.area.area_manager.areas: @@ -677,11 +703,15 @@ def net_cmd_ms(self, args): part = part[2:] if len(target_area) <= 0: self.client.send_ooc("No target areas found!") + # Deny the MS + self.client.send_command("xMS") return text = " ".join(part) except (ValueError, AreaError): self.client.send_ooc( "That does not look like a valid area ID!") + # Deny the MS + self.client.send_command("xMS") return if len(self.client.area.testimony) > 0 and ( text.lstrip().startswith(">") or text.lstrip().startswith("<") @@ -712,8 +742,12 @@ def net_cmd_ms(self, args): ) except Exception: self.client.send_ooc("Invalid index!") + # Deny the MS + self.client.send_command("xMS") return if msg_type not in ("chat", "0", "1", "2", "3", "4", "5"): + # Deny the MS + self.client.send_command("xMS") return # Disable the meme functionality of desk_mod that makes you selectively hide # jud/hld/hlp foregrounds when showing every other foreground due to how many @@ -726,27 +760,45 @@ def net_cmd_ms(self, args): if emote_mod == 4: emote_mod = 6 if emote_mod not in (0, 1, 2, 5, 6): + # Deny the MS + self.client.send_command("xMS") return if cid != self.client.char_id: + # Deny the MS + self.client.send_command("xMS") return if sfx_delay < 0: + # Deny the MS + self.client.send_command("xMS") return if "4" in str(button) and "" not in str(button): if not button.isdigit(): + # Deny the MS + self.client.send_command("xMS") return if evidence < 0: + # Deny the MS + self.client.send_command("xMS") return if ding not in (0, 1): + # Deny the MS + self.client.send_command("xMS") return if color < 0 or color >= 12: + # Deny the MS + self.client.send_command("xMS") return if len(showname) > 20: self.client.send_ooc("Your IC showname is way too long!") + # Deny the MS + self.client.send_command("xMS") return if not self.client.is_mod and showname.lstrip().lower().startswith("[m"): self.client.send_ooc( "Nice try! You may not spoof [M] tag in your showname." ) + # Deny the MS + self.client.send_command("xMS") return if (nonint_pre == 1 and button in range(1, 4)) or ( self.client.area.non_int_pres_only @@ -781,6 +833,8 @@ def net_cmd_ms(self, args): if len(text) > max_char: self.client.send_ooc("Your message is too long!") + # Deny the MS + self.client.send_command("xMS") return # Really simple spam protection that functions on the clientside pre-2.8.5, and really should've been serverside from the start @@ -796,6 +850,8 @@ def net_cmd_ms(self, args): self.client.send_ooc( "Your message is a repeat of the last one, don't spam!" ) + # Deny the MS + self.client.send_command("xMS") return # We are blankposting. @@ -823,6 +879,8 @@ def net_cmd_ms(self, args): and self.client in self.client.area.owners ): self.client.send_ooc("You can't whisper in this area!") + # Deny the MS + self.client.send_command("xMS") return part = text.split(" ") try: @@ -850,6 +908,8 @@ def net_cmd_ms(self, args): text = "}}}[W" + clients + "] {{{" + text except (ValueError, AreaError): self.client.send_ooc("Invalid targets!") + # Deny the MS + self.client.send_command("xMS") return if contains_URL( text.replace("}", "") @@ -864,6 +924,8 @@ def net_cmd_ms(self, args): .replace("\\f", "") ): self.client.send_ooc("You shouldn't send links in IC!") + # Deny the MS + self.client.send_command("xMS") return msg = dezalgo(text, self.server.zalgo_tolerance) @@ -1007,6 +1069,7 @@ def net_cmd_ms(self, args): frames_sfx, add, effect, + self.client.id, ) a_list = ", ".join([str(a.id) for a in target_area]) if not (self.client.area in target_area): @@ -1045,11 +1108,15 @@ def net_cmd_ms(self, args): add, effect, ) + # Make sure the client is not waiting on an MS packet back so no ghost MS remains + self.client.send_command("xMS") self.client.send_ooc(f"Broadcasting to areas {a_list}") except (AreaError, ValueError): self.client.send_ooc( "Your broadcast list is invalid! Do /clear_broadcast to reset it and /broadcast to set a new one." ) + # Deny the MS + self.client.send_command("xMS") return # If we are not whispering... @@ -1215,6 +1282,7 @@ def net_cmd_ms(self, args): frames_sfx, additive, effect, + self.client.id, targets=whisper_clients, ) self.client.area.send_owner_ic( @@ -1250,6 +1318,7 @@ def net_cmd_ms(self, args): frames_sfx, additive, effect, + self.client.id, ) def net_cmd_ct(self, args): diff --git a/server/tsuserver.py b/server/tsuserver.py index 6adf0d99..505ff5ba 100644 --- a/server/tsuserver.py +++ b/server/tsuserver.py @@ -83,6 +83,7 @@ def __init__(self): "expanded_desk_mods", "y_offset", "sfx_on_idle", + "msg_ghost", ] self.command_aliases = {}