From 997173f1c645ad1f2190c046a8874e5419531df8 Mon Sep 17 00:00:00 2001 From: moneromooo Date: Wed, 31 Dec 2014 09:49:20 +0000 Subject: [PATCH] Move some config from the IRC module to the config module --- tipbot/config.py | 4 ++++ tipbot/irc.py | 16 +++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tipbot/config.py b/tipbot/config.py index 9914c87..d5632ef 100644 --- a/tipbot/config.py +++ b/tipbot/config.py @@ -11,9 +11,13 @@ # tipbot_name = "monero-testnet-tipbot" + irc_network = 'irc.freenode.net' irc_port = 6667 irc_send_delay = 0.4 +irc_welcome_line = 'Welcome to the freenode Internet Relay Chat Network' +irc_homechan = '#txtptest000' +irc_timeout_seconds = 600 redis_host="127.0.0.1" redis_port=7777 diff --git a/tipbot/irc.py b/tipbot/irc.py index e526eb9..346ca01 100644 --- a/tipbot/irc.py +++ b/tipbot/irc.py @@ -15,15 +15,13 @@ import socket import select import time import string +import tipbot.config as config from tipbot.log import log_error, log_warn, log_info, log_log, log_IRCSEND, log_IRCRECV irc_line_delay = 0 irc = None irc_password = "" -irc_welcome_line = 'Welcome to the freenode Internet Relay Chat Network' -irc_homechan = '#txtptest000' -irc_timeout_seconds = 600 last_ping_time = time.time() irc_network = None irc_port = None @@ -67,7 +65,7 @@ def reconnect_to_irc(): connect_to_irc(irc_network,irc_port,irc_name,irc_password,irc_line_delay) def Send(msg): - SendIRC ('PRIVMSG ' + irc_homechan + ' : ' + msg) + SendIRC ('PRIVMSG ' + config.irc_homechan + ' : ' + msg) def SendTo(where,msg): SendIRC ('PRIVMSG ' + where + ' : ' + msg) @@ -214,8 +212,8 @@ def IRCLoop(on_idle,on_identified,on_command): on_idle() if data == None: - if time.time() - last_ping_time > irc_timeout_seconds: - log_warn('%s seconds without PING, reconnecting in 5 seconds' % irc_timeout_seconds) + if time.time() - last_ping_time > config.irc_timeout_seconds: + log_warn('%s seconds without PING, reconnecting in 5 seconds' % config.irc_timeout_seconds) time.sleep(5) last_ping_time = time.time() reconnect_to_irc(irc_network,irc_port) @@ -227,12 +225,12 @@ def IRCLoop(on_idle,on_identified,on_command): # consider any IRC data as a ping last_ping_time = time.time() - if data.find ( irc_welcome_line ) != -1: + if data.find ( config.irc_welcome_line ) != -1: userstable = dict() registered_users.clear() SendTo("nickserv", "IDENTIFY %s" % irc_password) - Join(irc_homechan) - #ScanWho(None,[irc_homechan]) + Join(config.irc_homechan) + #ScanWho(None,[config.irc_homechan]) if data.find ( 'PING' ) == 0: log_log('Got PING, replying PONG')