use a welcome handler to capture the bot's nickmask.
we do this deep in the server in order to have the split functionality use it properly. i still don't know if it handles server privacy masks properly (which would only be noticed if that cloak is sent when you connect). actually, on that note, this only works if the ircd sends the nickmask in 001. but hey, it works on one server at least
This commit is contained in:
parent
ae4411605d
commit
bf7074b76e
4
BUGS
4
BUGS
|
@ -1,12 +1,10 @@
|
||||||
dr.botzo --- BUGS
|
dr.botzo --- BUGS
|
||||||
|
|
||||||
* math in DrBotServerConnection.privmsg splitting is off. used to be a couple characters,
|
|
||||||
now is more. usermask thing?
|
|
||||||
* aliases referencing the bot by name, like !join #botname, just have MegaHAL fire twice
|
* aliases referencing the bot by name, like !join #botname, just have MegaHAL fire twice
|
||||||
this one may be more tricky as it involves alias order of operations and whatnot.
|
this one may be more tricky as it involves alias order of operations and whatnot.
|
||||||
maybe it's time to finally implement an internal message bus distinct from the pubmsg
|
maybe it's time to finally implement an internal message bus distinct from the pubmsg
|
||||||
handler
|
handler
|
||||||
* being in #chan and telling the bot to !part #chan is a crash if it can't message
|
* being in #chan and telling the bot to !part #chan is a crash if it can't message
|
||||||
#chan after it leaves
|
#chan after it leaves
|
||||||
* probably many, many more
|
|
||||||
* Countdown formatting has singular nouns for negative numbers (-21 day)
|
* Countdown formatting has singular nouns for negative numbers (-21 day)
|
||||||
|
* probably many, many more
|
||||||
|
|
21
DrBotIRC.py
21
DrBotIRC.py
|
@ -28,6 +28,24 @@ class DrBotServerConnection(irclib.ServerConnection):
|
||||||
|
|
||||||
"""Subclass irclib's ServerConnection, in order to expand privmsg."""
|
"""Subclass irclib's ServerConnection, in order to expand privmsg."""
|
||||||
|
|
||||||
|
hostname = None
|
||||||
|
|
||||||
|
def __init__(self, irclibobj):
|
||||||
|
irclib.ServerConnection.__init__(self, irclibobj)
|
||||||
|
|
||||||
|
# temporary. hopefully on_welcome() will set this
|
||||||
|
self.hostname = 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."""
|
||||||
|
what = event.arguments()[0]
|
||||||
|
|
||||||
|
match = re.search('(\S+!\S+@\S+)', what)
|
||||||
|
if match:
|
||||||
|
self.hostname = match.group(1)
|
||||||
|
|
||||||
def privmsg(self, target, text):
|
def privmsg(self, target, text):
|
||||||
"""Send a PRIVMSG command."""
|
"""Send a PRIVMSG command."""
|
||||||
|
|
||||||
|
@ -36,7 +54,8 @@ class DrBotServerConnection(irclib.ServerConnection):
|
||||||
# split messages that are too long. Max length is 512.
|
# 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 hostname has been
|
||||||
# masked by the ircd
|
# masked by the ircd
|
||||||
space = 512 - len('\r\n') - len('PRIVMSG ') - len(' :') - len(target) - len(self.nickname) - len('!') - len(self.username) - len('@') - len(socket.getfqdn())
|
# 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)
|
||||||
splitspace = space - (len(splitter) + 1)
|
splitspace = space - (len(splitter) + 1)
|
||||||
|
|
||||||
if len(text) > space:
|
if len(text) > space:
|
||||||
|
|
Loading…
Reference in New Issue