This commit is contained in:
GandC Snow 2021-10-25 10:46:48 +03:00
parent cdc7bc0fc4
commit 8680079893

View File

@ -2,34 +2,37 @@
##/dev/udp/ip/port##
from irc import client, connection
from socket import socket, AF_INET, SOCK_DGRAM
from configparser import ConfigParser
from os import chdir, path
from threading import Thread
host = '10.10.13.8'
port = 7777
port = '7777'
addr = (host,port)
irc_host = 's1.tomasgl.piv'
irc_port = '6667'
irc_chat_name = '#notifications'
irc_bot_nickname = 'GandC_LogMon_Bot'
s = socket(AF_INET, SOCK_DGRAM) # Socket creation
s.bind(addr) # Bind socket to ip
config = ConfigParser()
chdir(path.dirname(path.abspath(__file__)))
config.read('server.conf')
def on_connect(connection, event):
connection.mode(config['Global']['IRC_bot_nickname'], '+B')
connection.join(config['Global']['IRC_chat_name'])
connection.mode(irc_bot_nickname, '+B')
connection.join(irc_chat_name)
def on_join(connection, event):
connection.privmsg(config['Global']['IRC_chat_name'], 'Bot started')
connection.privmsg(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.connect(irc_host, int(irc_port), irc_bot_nickname)
irc.add_global_handler("welcome", on_connect)
irc.add_global_handler("join", on_join)
irc.add_global_handler('disconnect', on_disconnect)