Add +b flag;
This commit is contained in:
@@ -4,7 +4,7 @@ from time import time
|
|||||||
from socket import socket
|
from socket import socket
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
from threading import Thread
|
||||||
config = ConfigParser()
|
config = ConfigParser()
|
||||||
# Defaults
|
# Defaults
|
||||||
config['Global'] = {'check_delay': '5 * 60', # every 5 min
|
config['Global'] = {'check_delay': '5 * 60', # every 5 min
|
||||||
@@ -21,27 +21,29 @@ def check(host, port):
|
|||||||
sleep(int(config['Global']['attempts_delay']))
|
sleep(int(config['Global']['attempts_delay']))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
#def on_connect(connection, event):
|
def on_connect(connection, event):
|
||||||
# connection.mode(bot_nickname, '+x')
|
connection.mode(config['Global']['IRC_bot_nickname'], '+B')
|
||||||
# connection.join(IRC_chat_name)
|
connection.join(config['Global']['IRC_chat_name'])
|
||||||
|
|
||||||
def connect():
|
def on_join(connection, event):
|
||||||
reactor = client.Reactor()
|
connection.privmsg(config['Global']['IRC_chat_name'], 'Bot started')
|
||||||
irc = reactor.server()
|
|
||||||
irc.connect(config['Global']['IRC_host'], int(config['Global']['IRC_port']), config['Global']['IRC_bot_nickname'])
|
|
||||||
reactor.process_once(timeout=30)
|
|
||||||
irc.join(config['Global']['IRC_chat_name'])
|
|
||||||
reactor.process_once(timeout=30)
|
|
||||||
#irc.privmsg(config['Global']['IRC_chat_name'], 'Bot started')
|
|
||||||
print('Connected')
|
|
||||||
return irc, reactor
|
|
||||||
|
|
||||||
|
|
||||||
|
def on_disconnect(connection, event):
|
||||||
|
exit()
|
||||||
|
##
|
||||||
|
reactor = client.Reactor()
|
||||||
|
irc = reactor.server()
|
||||||
|
irc.connect(config['Global']['IRC_host'], int(config['Global']['IRC_port']), config['Global']['IRC_bot_nickname'])
|
||||||
|
irc.add_global_handler("welcome", on_connect)
|
||||||
|
irc.add_global_handler("join", on_join)
|
||||||
|
irc.add_global_handler('disconnect', on_disconnect)
|
||||||
|
Thread(target=reactor.process_forever).start()
|
||||||
|
##
|
||||||
hosts = config._sections
|
hosts = config._sections
|
||||||
check_delay = eval(config['Global']['check_delay'])
|
check_delay = eval(config['Global']['check_delay'])
|
||||||
|
|
||||||
last_check = 0
|
last_check = 0
|
||||||
irc, reactor = connect()
|
|
||||||
connection_states = {}
|
connection_states = {}
|
||||||
for host, services in hosts.items():
|
for host, services in hosts.items():
|
||||||
connection_states[host] = {}
|
connection_states[host] = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user