improve upon the splitting (which was excessive following the last commit).
clarify the terminology a bit, too
This commit is contained in:
parent
bf7074b76e
commit
c23b59d705
12
DrBotIRC.py
12
DrBotIRC.py
@ -28,23 +28,23 @@ class DrBotServerConnection(irclib.ServerConnection):
|
||||
|
||||
"""Subclass irclib's ServerConnection, in order to expand privmsg."""
|
||||
|
||||
hostname = None
|
||||
nickmask = None
|
||||
|
||||
def __init__(self, irclibobj):
|
||||
irclib.ServerConnection.__init__(self, irclibobj)
|
||||
|
||||
# temporary. hopefully on_welcome() will set this
|
||||
self.hostname = socket.getfqdn()
|
||||
self.nickmask = socket.getfqdn()
|
||||
|
||||
self.add_global_handler('welcome', self.on_welcome, 1)
|
||||
|
||||
def on_welcome(self, connection, event):
|
||||
"""Set the hostname that the ircd tells us is us."""
|
||||
"""Set the nickmask that the ircd tells us is us."""
|
||||
what = event.arguments()[0]
|
||||
|
||||
match = re.search('(\S+!\S+@\S+)', what)
|
||||
if match:
|
||||
self.hostname = match.group(1)
|
||||
self.nickmask = match.group(1)
|
||||
|
||||
def privmsg(self, target, text):
|
||||
"""Send a PRIVMSG command."""
|
||||
@ -52,10 +52,10 @@ class DrBotServerConnection(irclib.ServerConnection):
|
||||
splitter = "..."
|
||||
|
||||
# split messages that are too long. Max length is 512.
|
||||
# TODO: this does not properly handle when the hostname has been
|
||||
# TODO: this does not properly handle when the nickmask has been
|
||||
# masked by the ircd
|
||||
# is the above still the case?
|
||||
space = 512 - len('\r\n') - len('PRIVMSG ') - len(' :') - len(target) - len(self.nickname) - len('!') - len(self.username) - len('@') - len(self.hostname)
|
||||
space = 512 - len('\r\n') - len(' PRIVMSG ') - len(target) - len(' :') - len(self.nickmask) - len(' :')
|
||||
splitspace = space - (len(splitter) + 1)
|
||||
|
||||
if len(text) > space:
|
||||
|
Loading…
Reference in New Issue
Block a user