Ignore messages received before the bot is fully set up

This commit is contained in:
Vgr E. Barry 2017-01-17 12:52:21 -05:00
parent 740d14ef72
commit ad7e0f11ac
2 changed files with 12 additions and 4 deletions

View File

@ -6,10 +6,11 @@ import sys
import threading
import time
import traceback
import functools
import botconfig
import src.settings as var
from src import decorators, wolfgame, channels, hooks, users, errlog as log, stream_handler as alog
from src import decorators, wolfgame, events, channels, hooks, users, errlog as log, stream_handler as alog
from src.messages import messages
from src.utilities import reply
@ -106,6 +107,14 @@ def connect_callback(cli):
ping_server_timer(cli)
def setup_handler(evt, var, target):
target.client.command_handler["privmsg"] = on_privmsg
target.client.command_handler["notice"] = functools.partial(on_privmsg, notice=True)
events.remove_listener("who_end", setup_handler)
events.add_listener("who_end", setup_handler)
def mustregain(cli, server, bot_nick, nick, msg):
nonlocal regaincount

View File

@ -18,7 +18,6 @@
# THE SOFTWARE.
import traceback
import functools
import sys
import os
@ -53,8 +52,8 @@ from src import handler
def main():
src.plog("Connecting to {0}:{1}{2}".format(botconfig.HOST, "+" if botconfig.USE_SSL else "", botconfig.PORT))
cli = IRCClient(
{"privmsg": handler.on_privmsg,
"notice": functools.partial(handler.on_privmsg, notice=True),
{"privmsg": lambda *s: None,
"notice": lambda *s: None,
"": handler.unhandled},
host=botconfig.HOST,
port=botconfig.PORT,