add ChannelDB api for storing channel membership

This commit is contained in:
randomuser 2021-07-21 00:47:28 -05:00
parent ce2f416611
commit 1af43d6960
1 changed files with 24 additions and 0 deletions

24
channels.py Normal file
View File

@ -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()