From 297d31dab27054462bd97d82887bcf0f31f5a7a6 Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 10 Oct 2019 22:06:34 -0700 Subject: [PATCH] Add has-irc-modes capability (#620) --- docs/technical/pmodule-spec.md | 5 ++++- protocols/clientbot.py | 4 ++-- protocols/ircs2s_common.py | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/technical/pmodule-spec.md b/docs/technical/pmodule-spec.md index 8af282b..3245a4d 100644 --- a/docs/technical/pmodule-spec.md +++ b/docs/technical/pmodule-spec.md @@ -1,6 +1,6 @@ # PyLink Protocol Module Specification -***Last updated for 2.1-alpha2 (2019-06-23).*** +***Last updated for 2.1-alpha2 (2019-10-10).*** Starting with PyLink 2.x, a *protocol module* is any module containing a class derived from `PyLinkNetworkCore` (e.g. `InspIRCdProtocol`), along with a global `Class` attribute set equal to it (e.g. `Class = InspIRCdProtocol`). These modules do everything from managing connections to providing plugins with an API to send and receive data. New protocol modules may be implemented based off any of the classes in the following inheritance tree, with each containing a different amount of abstraction. @@ -137,6 +137,7 @@ As of writing, the following protocol capabilities (case-sensitive) are implemen - `can-track-servers` - determines whether servers are accurately tracked (for `servermaps` and other statistics) - `freeform-nicks` - if set, nicknames for PyLink's virtual clients are not subject to validity and nick collision checks. This implies the `slash-in-nicks` capability. - Note: PyLink already allows incoming nicks to be freeform, provided they are encoded correctly and don't cause parsing conflicts (i.e. containing reserved chars on IRC) +- `has-irc-modes` - whether IRC style modes are supported - `has-statusmsg` - whether STATUSMSG messages (e.g. `@#channel`) are supported - `has-ts` - determines whether channel and user timestamps are tracked (and not spoofed) - `slash-in-hosts` - determines whether `/` is allowed in hostnames @@ -261,6 +262,8 @@ In short, protocol modules have some very important jobs. If any of these aren't 7) Declare the correct set of protocol module capabilities to prevent confusing PyLink's plugins. ## Changes to this document +* 2019-10-10 (2.1-alpha2) + - Added protocol capability: `has-irc-modes` * 2019-06-23 (2.1-alpha2) - Added new protocol capabilities: `virtual-server` and `freeform-nicks` * 2018-07-11 (2.0.0) diff --git a/protocols/clientbot.py b/protocols/clientbot.py index 8566d9f..8a55d77 100644 --- a/protocols/clientbot.py +++ b/protocols/clientbot.py @@ -25,8 +25,8 @@ class ClientbotBaseProtocol(PyLinkNetworkCoreWithUtils): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.protocol_caps = {'visible-state-only', 'slash-in-nicks', 'slash-in-hosts', 'underscore-in-hosts', - 'freeform-nicks'} + self.protocol_caps |= {'visible-state-only', 'slash-in-nicks', 'slash-in-hosts', 'underscore-in-hosts', + 'freeform-nicks'} # Remove conf key checks for those not needed for Clientbot. self.conf_keys -= {'recvpass', 'sendpass', 'sid', 'sidrange', 'hostname'} diff --git a/protocols/ircs2s_common.py b/protocols/ircs2s_common.py index 1707e18..504eab3 100644 --- a/protocols/ircs2s_common.py +++ b/protocols/ircs2s_common.py @@ -61,6 +61,7 @@ class IRCCommonProtocol(IRCNetwork): self._caps = {} self._use_builtin_005_handling = False # Disabled by default for greater security + self.protocol_caps |= {'has-irc-modes'} def post_connect(self): self._caps.clear() @@ -281,8 +282,8 @@ class IRCS2SProtocol(IRCCommonProtocol): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.protocol_caps = {'can-spawn-clients', 'has-ts', 'can-host-relay', - 'can-track-servers'} + self.protocol_caps |= {'can-spawn-clients', 'has-ts', 'can-host-relay', + 'can-track-servers'} # Alias self.handle_squit = self._squit