Add a ControlSocket client to IRCBot.py, use it to trigger the epoll loop when a

github webhook has been caught!
This commit is contained in:
jesopo 2018-10-06 15:45:56 +01:00
parent 0a609ca695
commit 79aff93b5d
2 changed files with 9 additions and 2 deletions

View file

@ -41,4 +41,4 @@ class Module(ModuleManager.BaseModule):
self.events.on("send.stdout").call(target=channel, self.events.on("send.stdout").call(target=channel,
module_name="Github", server=server, message=line) module_name="Github", server=server, message=line)
self.bot.register_both(server) self.bot.trigger()

View file

@ -1,4 +1,4 @@
import os, select, sys, threading, time, traceback, uuid import os, select, socket, sys, threading, time, traceback, uuid
from src import ControlSocket, EventManager, Exports, IRCServer, Logging from src import ControlSocket, EventManager, Exports, IRCServer, Logging
from src import ModuleManager, utils from src import ModuleManager, utils
@ -26,6 +26,13 @@ class Bot(object):
self.control_socket = ControlSocket.ControlSocket(self) self.control_socket = ControlSocket.ControlSocket(self)
self.add_socket(self.control_socket) self.add_socket(self.control_socket)
self.control_socket_client = socket.socket(
socket.AF_UNIX, socket.SOCK_STREAM)
self.control_socket_client.connect(self.config["control-socket"])
def trigger(self):
self.control_socket_client.send(b"TRIGGER")
def add_server(self, server_id, connect=True): def add_server(self, server_id, connect=True):
(_, alias, hostname, port, password, ipv4, tls, bindhost, nickname, (_, alias, hostname, port, password, ipv4, tls, bindhost, nickname,
username, realname) = self.database.servers.get(server_id) username, realname) = self.database.servers.get(server_id)