diff options
| author | 2018-08-28 12:23:57 +0100 | |
|---|---|---|
| committer | 2018-08-28 12:23:57 +0100 | |
| commit | e5a5fa5c4b40918247be8486d27a1676b6d2b044 (patch) | |
| tree | 70e61a968a20134b01ea4e4f5611e4e254df06ae /IRCLog.py | |
| parent | Prevent users sending coins to themselves (diff) | |
| signature | ||
modules/logging.py -> IRCLogging.py; IRCLog.py -> IRCBuffer.py; change logging
to be an object on the server object instead of an event call
Diffstat (limited to 'IRCLog.py')
| -rw-r--r-- | IRCLog.py | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/IRCLog.py b/IRCLog.py deleted file mode 100644 index 834939e2..00000000 --- a/IRCLog.py +++ /dev/null @@ -1,43 +0,0 @@ -import re - -class Line(object): - def __init__(self, sender, message, action, from_self): - self.sender = sender - self.message = message - self.action = action - self.from_self = from_self - -class Log(object): - def __init__(self, bot): - self.lines = [] - self.max_lines = 64 - self._skip_next = False - def add_line(self, sender, message, action, from_self=False): - if not self._skip_next: - line = Line(sender, message, action, from_self) - self.lines.insert(0, line) - if len(self.lines) > self.max_lines: - self.lines.pop() - self._skip_next = False - def get(self, index=0, **kwargs): - from_self = kwargs.get("from_self", True) - for line in self.lines: - if line.from_self and not from_self: - continue - return line - def find(self, pattern, **kwargs): - from_self = kwargs.get("from_self", True) - for_user = kwargs.get("for_user", "") - for_user = for_user.lower() if for_user else None - not_pattern = kwargs.get("not_pattern", None) - for line in self.lines: - if line.from_self and not from_self: - continue - elif re.search(pattern, line.message): - if not_pattern and re.search(not_pattern, line.message): - continue - if for_user and not line.sender.lower() == for_user: - continue - return line - def skip_next(self): - self._skip_next = True |
