3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 09:19:23 +01:00

protocols: migrate away from irc.botdata (#273)

This commit is contained in:
James Lu 2017-03-05 00:06:19 -08:00
parent b4f70bdece
commit d318fbac77
7 changed files with 21 additions and 21 deletions

View File

@ -1,6 +1,6 @@
import time
from pylinkirc import utils
from pylinkirc import utils, conf
from pylinkirc.log import log
from pylinkirc.classes import *
from pylinkirc.protocols.ts6 import *
@ -79,7 +79,7 @@ class HybridProtocol(TS6Protocol):
f('CAPAB :TBURST DLN KNOCK UNDLN UNKLN KLN ENCAP IE EX HOPS CHW SVS CLUSTER EOB QS')
f('SERVER %s 0 :%s' % (self.irc.serverdata["hostname"],
self.irc.serverdata.get('serverdesc') or self.irc.botdata['serverdesc']))
self.irc.serverdata.get('serverdesc') or conf.conf['bot']['serverdesc']))
# send endburst now
self.irc.send(':%s EOB' % (self.irc.sid,))
@ -101,7 +101,7 @@ class HybridProtocol(TS6Protocol):
uid = self.uidgen[server].next_uid()
ts = ts or int(time.time())
realname = realname or self.irc.botdata['realname']
realname = realname or conf.conf['bot']['realname']
realhost = realhost or host
raw_modes = self.irc.joinModes(modes)
u = self.irc.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,

View File

@ -5,7 +5,7 @@ inspircd.py: InspIRCd 2.x protocol module for PyLink.
import time
import threading
from pylinkirc import utils
from pylinkirc import utils, conf
from pylinkirc.classes import *
from pylinkirc.log import log
from pylinkirc.protocols.ts6_common import *
@ -47,7 +47,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
uid = self.uidgen[server].next_uid()
ts = ts or int(time.time())
realname = realname or self.irc.botdata['realname']
realname = realname or conf.conf['bot']['realname']
realhost = realhost or host
raw_modes = self.irc.joinModes(modes)
u = self.irc.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,
@ -351,7 +351,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
uplink = uplink or self.irc.sid
name = name.lower()
# "desc" defaults to the configured server description.
desc = desc or self.irc.serverdata.get('serverdesc') or self.irc.botdata['serverdesc']
desc = desc or self.irc.serverdata.get('serverdesc') or conf.conf['bot']['serverdesc']
if sid is None: # No sid given; generate one!
sid = self.sidgen.next_sid()
assert len(sid) == 3, "Incorrect SID length"
@ -398,7 +398,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
host = self.irc.serverdata["hostname"]
f('SERVER {host} {Pass} 0 {sid} :{sdesc}'.format(host=host,
Pass=self.irc.serverdata["sendpass"], sid=self.irc.sid,
sdesc=self.irc.serverdata.get('serverdesc') or self.irc.botdata['serverdesc']))
sdesc=self.irc.serverdata.get('serverdesc') or conf.conf['bot']['serverdesc']))
self._send(self.irc.sid, 'BURST %s' % ts)
# InspIRCd sends VERSION data on link, instead of whenever requested by a client.

View File

@ -7,7 +7,7 @@ import struct
from ipaddress import ip_address
import time
from pylinkirc import utils, structures
from pylinkirc import utils, structures, conf
from pylinkirc.classes import *
from pylinkirc.log import log
from pylinkirc.protocols.ircs2s_common import *
@ -274,7 +274,7 @@ class P10Protocol(IRCS2SProtocol):
# Fill in all the values we need
ts = ts or int(time.time())
realname = realname or self.irc.botdata['realname']
realname = realname or conf.conf['bot']['realname']
realhost = realhost or host
raw_modes = self.irc.joinModes(modes)
@ -642,7 +642,7 @@ class P10Protocol(IRCS2SProtocol):
# <- SERVER nefarious.midnight.vpn 1 1460673022 1460673239 J10 ABP]] +h6 :Nefarious2 test server
uplink = uplink or self.irc.sid
name = name.lower()
desc = desc or self.irc.serverdata.get('serverdesc') or self.irc.botdata['serverdesc']
desc = desc or self.irc.serverdata.get('serverdesc') or conf.conf['bot']['serverdesc']
if sid is None: # No sid given; generate one!
sid = self.sidgen.next_sid()
@ -764,7 +764,7 @@ class P10Protocol(IRCS2SProtocol):
# Encode our SID using P10 Base64.
self.irc.sid = sid = p10b64encode(self.irc.serverdata["sid"])
desc = self.irc.serverdata.get('serverdesc') or self.irc.botdata['serverdesc']
desc = self.irc.serverdata.get('serverdesc') or conf.conf['bot']['serverdesc']
# Enumerate modes, from https://github.com/evilnet/nefarious2/blob/master/doc/modes.txt
cmodes = {'op': 'o', 'voice': 'v', 'private': 'p', 'secret': 's', 'moderated': 'm',

View File

@ -1,6 +1,6 @@
import time
from pylinkirc import utils
from pylinkirc import utils, conf
from pylinkirc.log import log
from pylinkirc.classes import *
from pylinkirc.protocols.ts6 import *
@ -58,7 +58,7 @@ class RatboxProtocol(TS6Protocol):
uid = self.uidgen[server].next_uid()
ts = ts or int(time.time())
realname = realname or self.irc.botdata['realname']
realname = realname or conf.conf['bot']['realname']
raw_modes = self.irc.joinModes(modes)
orig_realhost = realhost

View File

@ -5,7 +5,7 @@ ts6.py: PyLink protocol module for TS6-based IRCds (charybdis, elemental-ircd).
import time
import re
from pylinkirc import utils
from pylinkirc import utils, conf
from pylinkirc.classes import *
from pylinkirc.log import log
from pylinkirc.protocols.ts6_common import *
@ -46,7 +46,7 @@ class TS6Protocol(TS6BaseProtocol):
# parameters: nickname, hopcount, nickTS, umodes, username,
# visible hostname, IP address, UID, real hostname, account name, gecos
ts = ts or int(time.time())
realname = realname or self.irc.botdata['realname']
realname = realname or conf.conf['bot']['realname']
realhost = realhost or host
raw_modes = self.irc.joinModes(modes)
u = self.irc.users[uid] = IrcUser(nick, ts, uid, server, ident=ident, host=host, realname=realname,
@ -338,7 +338,7 @@ class TS6Protocol(TS6BaseProtocol):
f('CAPAB :QS ENCAP EX CHW IE KNOCK SAVE SERVICES TB EUID RSFNC EOPMOD SAVETS_100')
f('SERVER %s 0 :%s' % (self.irc.serverdata["hostname"],
self.irc.serverdata.get('serverdesc') or self.irc.botdata['serverdesc']))
self.irc.serverdata.get('serverdesc') or conf.conf['bot']['serverdesc']))
# Finally, end all the initialization with a PING - that's Charybdis'
# way of saying end-of-burst :)

View File

@ -5,7 +5,7 @@ ts6_common.py: Common base protocol class with functions shared by the UnrealIRC
import string
import time
from pylinkirc import utils, structures
from pylinkirc import utils, structures, conf
from pylinkirc.classes import *
from pylinkirc.log import log
from pylinkirc.protocols.ircs2s_common import *
@ -260,7 +260,7 @@ class TS6BaseProtocol(IRCS2SProtocol):
# -> :0AL SID test.server 1 0XY :some silly pseudoserver
uplink = uplink or self.irc.sid
name = name.lower()
desc = desc or self.irc.serverdata.get('serverdesc') or self.irc.botdata['serverdesc']
desc = desc or self.irc.serverdata.get('serverdesc') or conf.conf['bot']['serverdesc']
if sid is None: # No sid given; generate one!
sid = self.sidgen.next_sid()
assert len(sid) == 3, "Incorrect SID length"

View File

@ -7,7 +7,7 @@ import codecs
import socket
import re
from pylinkirc import utils
from pylinkirc import utils, conf
from pylinkirc.classes import *
from pylinkirc.log import log
from pylinkirc.protocols.ts6_common import *
@ -73,7 +73,7 @@ class UnrealProtocol(TS6BaseProtocol):
uid = self.uidgen[server].next_uid()
ts = ts or int(time.time())
realname = realname or self.irc.botdata['realname']
realname = realname or conf.conf['bot']['realname']
realhost = realhost or host
# Add +xt so that vHost cloaking always works.
@ -367,7 +367,7 @@ class UnrealProtocol(TS6BaseProtocol):
# ESVID - Supports account names in services stamps instead of just the signon time.
# AFAIK this doesn't actually affect services' behaviour?
f('PROTOCTL SJOIN SJ3 NOQUIT NICKv2 VL UMODE2 PROTOCTL NICKIP EAUTH=%s SID=%s VHP ESVID' % (self.irc.serverdata["hostname"], self.irc.sid))
sdesc = self.irc.serverdata.get('serverdesc') or self.irc.botdata['serverdesc']
sdesc = self.irc.serverdata.get('serverdesc') or conf.conf['bot']['serverdesc']
f('SERVER %s 1 U%s-h6e-%s :%s' % (host, self.proto_ver, self.irc.sid, sdesc))
f('NETINFO 1 %s %s * 0 0 0 :%s' % (self.irc.start_ts, self.proto_ver, self.irc.serverdata.get("netname", self.irc.name)))
self._send(self.irc.sid, 'EOS')