diff --git a/modules/github/__init__.py b/modules/github/__init__.py index d76762d3..b38c652c 100644 --- a/modules/github/__init__.py +++ b/modules/github/__init__.py @@ -584,6 +584,8 @@ class Module(ModuleManager.BaseModule): else: action_desc = "%s %s" % ( utils.irc.color("closed", COLOR_NEGATIVE), number) + elif action == "ready_for_review": + action_desc = "marked %s ready for review" % number elif action == "synchronize": action_desc = "committed to %s" % number diff --git a/src/IRCBot.py b/src/IRCBot.py index f01bb604..de2042fb 100644 --- a/src/IRCBot.py +++ b/src/IRCBot.py @@ -30,11 +30,11 @@ class Bot(object): self._event_queue = queue.Queue() - self._read_poll = select.epoll() - self._write_poll = select.epoll() + self._read_poll = select.poll() + self._write_poll = select.poll() self._rtrigger_server, self._rtrigger_client = socket.socketpair() - self._read_poll.register(self._rtrigger_server.fileno(), select.EPOLLIN) + self._read_poll.register(self._rtrigger_server.fileno(), select.POLLIN) self._rtrigger_lock = threading.Lock() self._rtriggered = False @@ -145,7 +145,7 @@ class Bot(object): [str(server), str(e)]) return False self.servers[server.fileno()] = server - self._read_poll.register(server.fileno(), select.EPOLLIN) + self._read_poll.register(server.fileno(), select.POLLIN) return True def next_send(self) -> typing.Optional[float]: @@ -182,7 +182,8 @@ class Bot(object): timeouts.append(self.next_ping()) timeouts.append(self.next_read_timeout()) timeouts.append(self.cache.next_expiration()) - return min([timeout for timeout in timeouts if not timeout == None]) + min_secs = min([timeout for timeout in timeouts if not timeout == None]) + return min_secs*1000 # return milliseconds def disconnect(self, server: IRCServer.Server): del self.servers[server.fileno()] @@ -249,7 +250,7 @@ class Bot(object): writeable = False for fd, server in self.servers.items(): if server.socket.waiting_immediate_send(): - self._write_poll.register(fd, select.EPOLLOUT) + self._write_poll.register(fd, select.POLLOUT) writeable = True if not writeable: @@ -259,7 +260,7 @@ class Bot(object): events = self._write_poll.poll() for fd, event in events: - if event & select.EPOLLOUT: + if event & select.POLLOUT: self._write_poll.unregister(fd) if fd in self.servers: server = self.servers[fd] @@ -296,7 +297,7 @@ class Bot(object): continue server = self.servers[fd] - if event & select.EPOLLIN: + if event & select.POLLIN: lines = server.read() if lines == None: server.disconnect() @@ -304,8 +305,8 @@ class Bot(object): self.trigger(self._post_read_factory(server, lines), False) - elif event & select.EPOLLHUP: - self.log.warn("Recieved EPOLLHUP for %s", [str(server)]) + elif event & select.POLLHUP: + self.log.warn("Recieved POLLHUP for %s", [str(server)]) server.disconnect() def _check(self): diff --git a/src/IRCBuffer.py b/src/IRCBuffer.py index 1415fd48..3dccb07b 100644 --- a/src/IRCBuffer.py +++ b/src/IRCBuffer.py @@ -1,6 +1,8 @@ -import re, typing +import collections, re, typing from src import IRCBot, IRCServer, utils +MAX_LINES = 64 + class BufferLine(object): def __init__(self, sender: str, message: str, action: bool, tags: dict, from_self: bool, method: str): @@ -15,17 +17,15 @@ class Buffer(object): def __init__(self, bot: "IRCBot.Bot", server: "IRCServer.Server"): self.bot = bot self.server = server - self.lines = [] # type: typing.List[BufferLine] - self.max_lines = 64 + self._lines = collections.deque(maxlen=MAX_LINES + ) # type: typing.Deque[BufferLine] self._skip_next = False def _add_message(self, sender: str, message: str, action: bool, tags: dict, from_self: bool, method: str): if not self._skip_next: line = BufferLine(sender, message, action, tags, from_self, method) - self.lines.insert(0, line) - if len(self.lines) > self.max_lines: - self.lines.pop() + self._lines.appendleft(line) self._skip_next = False def add_message(self, sender: str, message: str, action: bool, tags: dict, from_self: bool=False): @@ -36,7 +36,7 @@ class Buffer(object): def get(self, index: int=0, **kwargs) -> typing.Optional[BufferLine]: from_self = kwargs.get("from_self", True) - for line in self.lines: + for line in self._lines: if line.from_self and not from_self: continue return line @@ -47,7 +47,7 @@ class Buffer(object): for_user = kwargs.get("for_user", "") for_user = self.server.irc_lower(for_user) if for_user else None not_pattern = kwargs.get("not_pattern", None) - for line in self.lines: + for line in self._lines: if line.from_self and not from_self: continue elif re.search(pattern, line.message): @@ -61,7 +61,7 @@ class Buffer(object): def find_from(self, nickname: str) -> typing.Optional[BufferLine]: nickname_lower = self.server.irc_lower(nickname) - for line in self.lines: + for line in self._lines: if (not line.from_self and self.server.irc_lower(line.sender) == nickname_lower): return line diff --git a/src/Logging.py b/src/Logging.py index 5c3d873c..bb7a4dbe 100644 --- a/src/Logging.py +++ b/src/Logging.py @@ -61,5 +61,6 @@ class Log(object): self._log(message, params, logging.ERROR, kwargs) def critical(self, message: str, params: typing.List=None, **kwargs): self._log(message, params, logging.CRITICAL, kwargs) - def _log(self, message: str, params: typing.List, level: int, kwargs: dict): + def _log(self, message: str, params: typing.Optional[typing.List], + level: int, kwargs: dict): self.logger.log(level, message, *(params or []), **kwargs)