Add +b flag;

This commit is contained in:
GandC Snow 2021-10-18 16:43:37 +03:00
parent 531734ea15
commit 91589bc15b

View File

@ -4,7 +4,7 @@ from time import time
from socket import socket
from configparser import ConfigParser
from time import sleep
from threading import Thread
config = ConfigParser()
# Defaults
config['Global'] = {'check_delay': '5 * 60', # every 5 min
@ -21,27 +21,29 @@ def check(host, port):
sleep(int(config['Global']['attempts_delay']))
return False
#def on_connect(connection, event):
# connection.mode(bot_nickname, '+x')
# connection.join(IRC_chat_name)
def on_connect(connection, event):
connection.mode(config['Global']['IRC_bot_nickname'], '+B')
connection.join(config['Global']['IRC_chat_name'])
def connect():
reactor = client.Reactor()
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_join(connection, event):
connection.privmsg(config['Global']['IRC_chat_name'], 'Bot started')
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
check_delay = eval(config['Global']['check_delay'])
last_check = 0
irc, reactor = connect()
connection_states = {}
for host, services in hosts.items():
connection_states[host] = {}