don't add the empty string to additional nicks
thinko on my part, this was making the regex for matching all nicks to '|nick' when the field is '', because of split producing ['']. in particular this was making markov trigger on every line
This commit is contained in:
parent
3aa3fb14e4
commit
43f2b09057
@ -165,14 +165,19 @@ class DrReactor(irc.client.Reactor):
|
||||
event.original_msg = what
|
||||
|
||||
# check if we were addressed or not
|
||||
all_nicks = '|'.join(connection.server_config.additional_addressed_nicks.split('\n') +
|
||||
[connection.get_nickname()])
|
||||
if connection.server_config.additional_addressed_nicks:
|
||||
all_nicks = '|'.join(connection.server_config.additional_addressed_nicks.split('\n') +
|
||||
[connection.get_nickname()])
|
||||
else:
|
||||
all_nicks = connection.get_nickname()
|
||||
addressed_pattern = r'^(({nicks})[:,]|@({nicks}))\s+(?P<addressed_msg>.*)'.format(nicks=all_nicks)
|
||||
match = re.match(addressed_pattern, what, re.IGNORECASE)
|
||||
if match:
|
||||
event.addressed = True
|
||||
event.addressed_msg = match.group('addressed_msg')
|
||||
|
||||
log.debug("all_nicks: %s, addressed: %s", all_nicks, event.addressed)
|
||||
|
||||
# only do aliasing for pubmsg/privmsg
|
||||
log.debug("checking for alias for %s", what)
|
||||
|
||||
@ -531,10 +536,11 @@ class IRCBot(irc.client.SimpleIRCClient):
|
||||
log.debug("welcome: %s", what)
|
||||
|
||||
# run automsg commands
|
||||
for cmd in self.server_config.post_connect.split('\n'):
|
||||
# TODO NOTE: if the bot is sending something that changes the vhost
|
||||
# (like 'hostserv on') we don't pick it up
|
||||
self.connection.privmsg(cmd.split(' ')[0], ' '.join(cmd.split(' ')[1:]))
|
||||
if self.server_config.post_connect:
|
||||
for cmd in self.server_config.post_connect.split('\n'):
|
||||
# TODO NOTE: if the bot is sending something that changes the vhost
|
||||
# (like 'hostserv on') we don't pick it up
|
||||
self.connection.privmsg(cmd.split(' ')[0], ' '.join(cmd.split(' ')[1:]))
|
||||
|
||||
# sleep before doing autojoins
|
||||
time.sleep(self.server_config.delay_before_joins)
|
||||
|
@ -61,8 +61,11 @@ class Markov(Plugin):
|
||||
def handle_chatter(self, connection, event):
|
||||
"""Learn from IRC chatter."""
|
||||
what = event.arguments[0]
|
||||
all_nicks = '|'.join(connection.server_config.additional_addressed_nicks.split('\n') +
|
||||
[connection.get_nickname()])
|
||||
if connection.server_config.additional_addressed_nicks:
|
||||
all_nicks = '|'.join(connection.server_config.additional_addressed_nicks.split('\n') +
|
||||
[connection.get_nickname()])
|
||||
else:
|
||||
all_nicks = connection.get_nickname()
|
||||
trimmed_what = re.sub(r'^(({nicks})[:,]|@({nicks}))\s+'.format(nicks=all_nicks), '', what)
|
||||
nick = irc.client.NickMask(event.source).nick
|
||||
target = reply_destination_for_event(event)
|
||||
|
Loading…
Reference in New Issue
Block a user