3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-26 20:24:34 +01:00

ts6: add support for ChatIRCd

This depreates the "use_elemental_modes" setting on ts6 networks, and replaces it with an "ircd" option targetting charybdis, elemental-ircd, or chatircd
Closes #339.
This commit is contained in:
James Lu 2017-07-12 21:23:42 -07:00
parent b081270aa1
commit 3d27e4a347
2 changed files with 29 additions and 12 deletions

View File

@ -239,21 +239,20 @@ servers:
# Note: /'s in nicks are automatically converted to |'s for TS6 # Note: /'s in nicks are automatically converted to |'s for TS6
# networks (charybdis, etc.), since they don't allow "/" in nicks. # networks (charybdis, etc.), since they don't allow "/" in nicks.
separator: "|" #separator: "|"
# The following options are specific to TS6 servers: # The following options are specific to TS6 servers:
# Toggles owner (+y), admin (+a), and halfop (+h) support for # Toggles owner (+y), admin (+a), and halfop (+h) support for
# shadowircd/elemental-ircd. # shadowircd/elemental-ircd/chatircd. These default to off for the best compatibility.
# This defaults to off for the best compatibility. #use_owner: false
use_owner: false #use_admin: false
use_admin: false #use_halfop: false
use_halfop: false
# Toggles support of shadowircd/elemental-ircd specific channel modes: # Sets the IRCd (channel/user mode set) to target - currently supported values include
# +T (no notice), +u (hidden ban list), +E (no kicks), +J (blocks kickrejoin), # 'chatircd', 'charybdis', and 'elemental' (elemental-ircd). This option defaults to
# +K (no repeat messages), +d (no nick changes), and user modes: # 'charybdis' if not set, and replaces the "use_elemental_modes" option from PyLink 1.2
# +B (bot), +C (blocks CTCP), +D (deaf), +V (no invites), +I (hides WHOIS channel list) # and earlier.
use_elemental_modes: false #ircd: charybdis
unrealnet: unrealnet:
ip: 1.2.3.4 ip: 1.2.3.4

View File

@ -11,6 +11,8 @@ from pylinkirc.log import log
from pylinkirc.protocols.ts6_common import * from pylinkirc.protocols.ts6_common import *
class TS6Protocol(TS6BaseProtocol): class TS6Protocol(TS6BaseProtocol):
SUPPORTED_IRCDS = ('charybdis', 'elemental', 'chatircd')
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.protocol_caps |= {'slash-in-hosts'} self.protocol_caps |= {'slash-in-hosts'}
@ -287,11 +289,19 @@ class TS6Protocol(TS6BaseProtocol):
'*A': '', '*B': '', '*C': '', '*D': 'DSaiowsQRgzlxp'} '*A': '', '*B': '', '*C': '', '*D': 'DSaiowsQRgzlxp'}
self.umodes = chary_umodes self.umodes = chary_umodes
# Find the target IRCd and update the mode dictionaries as applicable.
target_ircd = self.serverdata.get('ircd', 'elemental' if self.serverdata.get('use_elemental_modes') else 'charybdis')
target_ircd = target_ircd.lower()
if target_ircd not in self.SUPPORTED_IRCDS:
log.warning("(%s) Unsupported IRCd %r; falling back to 'charybdis' instead", self.name, target_ircd)
target_ircd = 'charybdis'
# Toggles support of shadowircd/elemental-ircd specific channel modes: # Toggles support of shadowircd/elemental-ircd specific channel modes:
# +T (no notice), +u (hidden ban list), +E (no kicks), +J (blocks kickrejoin), # +T (no notice), +u (hidden ban list), +E (no kicks), +J (blocks kickrejoin),
# +K (no repeat messages), +d (no nick changes), and user modes: # +K (no repeat messages), +d (no nick changes), and user modes:
# +B (bot), +C (blocks CTCP), +V (no invites), +I (hides channel list) # +B (bot), +C (blocks CTCP), +V (no invites), +I (hides channel list)
if self.serverdata.get('use_elemental_modes'): if target_ircd == 'elemental':
elemental_cmodes = {'hiddenbans': 'u', 'nokick': 'E', elemental_cmodes = {'hiddenbans': 'u', 'nokick': 'E',
'kicknorejoin': 'J', 'repeat': 'K', 'nonick': 'd', 'kicknorejoin': 'J', 'repeat': 'K', 'nonick': 'd',
'blockcaps': 'G'} 'blockcaps': 'G'}
@ -301,6 +311,14 @@ class TS6Protocol(TS6BaseProtocol):
elemental_umodes = {'noctcp': 'C', 'bot': 'B', 'noinvite': 'V', 'hidechans': 'I'} elemental_umodes = {'noctcp': 'C', 'bot': 'B', 'noinvite': 'V', 'hidechans': 'I'}
self.umodes.update(elemental_umodes) self.umodes.update(elemental_umodes)
self.umodes['*D'] += ''.join(elemental_umodes.values()) self.umodes['*D'] += ''.join(elemental_umodes.values())
elif target_ircd == 'chatircd':
chatircd_cmodes = {'netadminonly': 'N'}
self.cmodes.update(chatircd_cmodes)
self.cmodes['*D'] += ''.join(chatircd_cmodes.values())
chatircd_umodes = {'netadmin': 'n', 'bot': 'B', 'callerid_sslonly': 't'}
self.umodes.update(chatircd_umodes)
self.umodes['*D'] += ''.join(chatircd_umodes.values())
# https://github.com/grawity/irc-docs/blob/master/server/ts6.txt#L55 # https://github.com/grawity/irc-docs/blob/master/server/ts6.txt#L55
f('PASS %s TS 6 %s' % (self.serverdata["sendpass"], self.sid)) f('PASS %s TS 6 %s' % (self.serverdata["sendpass"], self.sid))