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

core: make hostmask fetching a shared function

This commit is contained in:
James Lu 2016-08-12 19:18:56 -07:00
parent 63f40c9565
commit a76bd8c5b2
2 changed files with 9 additions and 4 deletions

View File

@ -276,7 +276,7 @@ class Irc():
self.proto.connect()
log.info('(%s) Enumerating our own SID %s', self.name, self.sid)
host = self.serverdata.get('hostname', world.fallback_hostname)
host = self.hostname()
self.servers[self.sid] = IrcServer(None, host, internal=True,
desc=self.serverdata.get('serverdesc')
@ -810,10 +810,15 @@ class Irc():
Returns a detailed version string including the PyLink daemon version,
the protocol module in use, and the server hostname.
"""
fullversion = 'PyLink-%s. %s :[protocol:%s]' % (__version__, self.serverdata.get('hostname', world.fallback_hostname),
self.protoname)
fullversion = 'PyLink-%s. %s :[protocol:%s]' % (__version__, self.hostname(), self.protoname)
return fullversion
def hostname(self):
"""
Returns the server hostname used by PyLink on the given server.
"""
return self.serverdata.get('hostname', world.fallback_hostname)
### State checking functions
def nickToUid(self, nick):
"""Looks up the UID of a user with the given nick, if one is present."""

View File

@ -27,7 +27,7 @@ def spawn_service(irc, source, command, args):
ident = irc.serverdata.get("%s_ident" % name) or conf.conf.get(name, {}).get('ident') or sbot.ident or name
# TODO: make this configurable?
host = irc.serverdata.get("hostname", world.fallback_hostname)
host = irc.hostname()
# Spawning service clients with these umodes where supported. servprotect usage is a
# configuration option.