mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-11 12:42:34 +01:00
Add support for oper notices (GLOBOPS/OPERWALL) (#511)
This commit is contained in:
parent
2ae72d6723
commit
e25e3834a8
@ -1,6 +1,6 @@
|
||||
# PyLink Protocol Module Specification
|
||||
|
||||
***Last updated for 2.1-alpha2 (2019-11-02).***
|
||||
***Last updated for 3.1-dev (2021-06-15).***
|
||||
|
||||
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.
|
||||
|
||||
@ -82,6 +82,8 @@ Unless otherwise noted, the camel-case variants of command functions (e.g. "`spa
|
||||
|
||||
- **`nick`**`(self, source, newnick)` - Changes the nick of a PyLink client.
|
||||
|
||||
- **`oper_notice`**`(self, source, target)` - Sends a notice to all operators on the network.
|
||||
|
||||
- **`notice`**`(self, source, target, text)` - Sends a NOTICE from a PyLink client or server.
|
||||
|
||||
- **`numeric`**`(self, source, numeric, target, text)` - Sends a raw numeric `numeric` with `text` from the `source` server to `target`. This should raise `NotImplementedError` if not supported on a protocol.
|
||||
@ -263,6 +265,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
|
||||
* 2021-06-15 (3.1-dev)
|
||||
- Added `oper_notice()` function to send notices to opers (GLOBOPS / OPERWALL on most IRCds)
|
||||
* 2019-11-02 (2.1-beta1)
|
||||
- Added protocol capability: `can-manage-bot-channels`
|
||||
* 2019-10-10 (2.1-beta1)
|
||||
|
@ -147,6 +147,12 @@ class HybridProtocol(TS6Protocol):
|
||||
else:
|
||||
raise NotImplementedError("Changing field %r of a client is unsupported by this protocol." % field)
|
||||
|
||||
def oper_notice(self, source, text):
|
||||
"""
|
||||
Send a message to all opers.
|
||||
"""
|
||||
self._send_with_prefix(source, 'GLOBOPS :%s' % text)
|
||||
|
||||
def set_server_ban(self, source, duration, user='*', host='*', reason='User banned'):
|
||||
"""
|
||||
Sets a server ban.
|
||||
|
@ -334,6 +334,12 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
|
||||
self.call_hooks([self.sid, 'CHGNAME',
|
||||
{'target': target, 'newgecos': text}])
|
||||
def oper_notice(self, source, text):
|
||||
"""
|
||||
Send a message to all opers.
|
||||
"""
|
||||
# <- :70M SNONOTICE G :From jlu5: aaaaaa
|
||||
self._send_with_prefix(self.sid, 'SNONOTICE G :From %s: %s' % (self.get_friendly_name(source), text))
|
||||
|
||||
def numeric(self, source, numeric, target, text):
|
||||
"""Sends raw numerics from a server to a remote client."""
|
||||
|
@ -385,6 +385,12 @@ class IRCS2SProtocol(IRCCommonProtocol):
|
||||
# handle_part() does that just fine.
|
||||
self.handle_part(target, 'KICK', [channel])
|
||||
|
||||
def oper_notice(self, source, text):
|
||||
"""
|
||||
Send a message to all opers.
|
||||
"""
|
||||
self._send_with_prefix(source, 'WALLOPS :%s' % text)
|
||||
|
||||
def numeric(self, source, numeric, target, text):
|
||||
"""Sends raw numerics from a server to a remote client. This is used for WHOIS replies."""
|
||||
# Mangle the target for IRCds that require it.
|
||||
|
@ -526,6 +526,12 @@ class P10Protocol(IRCS2SProtocol):
|
||||
# <- AB 311 AyAAA jlu5 ~jlu5 nefarious.midnight.vpn * :realname
|
||||
self._send_with_prefix(source, '%s %s %s' % (numeric, target, text))
|
||||
|
||||
def oper_notice(self, source, text):
|
||||
"""
|
||||
Send a message to all opers.
|
||||
"""
|
||||
self._send_with_prefix(source, 'WA :%s' % text)
|
||||
|
||||
def part(self, client, channel, reason=None):
|
||||
"""Sends a part from a PyLink client."""
|
||||
|
||||
|
@ -117,6 +117,15 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
self._channels[channel].users.add(client)
|
||||
self.users[client].channels.add(channel)
|
||||
|
||||
def oper_notice(self, source, text):
|
||||
"""
|
||||
Send a message to all opers.
|
||||
"""
|
||||
if self.is_internal_server(source):
|
||||
# Charybdis TS6 only allows OPERWALL from users
|
||||
source = self.pseudoclient.uid
|
||||
self._send_with_prefix(source, 'OPERWALL :%s' % text)
|
||||
|
||||
def sjoin(self, server, channel, users, ts=None, modes=set()):
|
||||
"""Sends an SJOIN for a group of users to a channel.
|
||||
|
||||
|
@ -312,6 +312,12 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
joinedmodes = self.join_modes(modes)
|
||||
self._send_with_prefix(target, 'UMODE2 %s' % joinedmodes)
|
||||
|
||||
def oper_notice(self, source, text):
|
||||
"""
|
||||
Send a message to all opers.
|
||||
"""
|
||||
self._send_with_prefix(source, 'GLOBOPS :%s' % text)
|
||||
|
||||
def set_server_ban(self, source, duration, user='*', host='*', reason='User banned'):
|
||||
"""
|
||||
Sets a server ban.
|
||||
|
Loading…
Reference in New Issue
Block a user