From 1af43d6960a43281f97584604e117ee613e61810 Mon Sep 17 00:00:00 2001 From: randomuser Date: Wed, 21 Jul 2021 00:47:28 -0500 Subject: [PATCH] add ChannelDB api for storing channel membership --- channels.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 channels.py diff --git a/channels.py b/channels.py new file mode 100644 index 0000000..addfa1a --- /dev/null +++ b/channels.py @@ -0,0 +1,24 @@ +class ChannelDB: + def __init__(self, location=None): + self.channels = [] + if not location == None: + self.read(location) + + def read(self, location): + fd = open(location, "r") + [self.channels.append(i.rstrip()) for i in fd.readlines()] + fd.close() + + def add(self, channel): + self.channels.append(channel) + + def remove(self, channel): + self.channels.remove(channel) + + def list(self): + return self.channels + + def write(self, location): + fd = open(location, "w") + [fd.write(i + "\n") for i in self.channels] + fd.close()