isengard-bot/sharedBuffer.py

19 lines
514 B
Python
Raw Normal View History

2022-02-05 00:46:57 +01:00
class SharedBuffer:
def __init__(self, linkedBot):
self.buf = []
self.linkedBot = linkedBot
def flush(self):
for msg in self.buf:
self.linkedBot.send_message(
mto=msg.split("|")[0],
mbody=msg.split("|")[1],
mtype='groupchat')
self.buf.pop(self.buf.index(msg))
def push(self, msg):
self.buf.append(msg)
if len(self.buf) > 0:
self.flush()