chan_dir = ".config/gab/channels" ## not used yet. todo: move all gab channel logs to this dir
log = {}
help_text = "GAB - A simple chat interface\n\nsyntax: gab [flag] [value]\n\nflag value\n-------------------- ---------------\n-h, --help, help None\n-m, --msg, msg Quoted text with the msg being added to chat\n-l, --list, list An integer representing the number of rows you\'d like to view, default 5\n-b, --block, block A username to block/ignore\n-u, --unblock, unblock A username to unblock/unignore\n-c, --channel, channel Name of another channel you would like to load"
help_text = """
GAB - A simple chat interface
syntax: gab [flag] [value]
flag value
-------------------- ---------------
-h, --help, help
-m, --msg, msg Quoted text with the msg being added to chat
-l, --list, list An integer representing the number of rows you'd like
to view, default 5
-b, --block, block A username to block/ignore
-u, --unblock, unblock A username to unblock/unignore
-c, --channel, channel Name of the channel you would like to join or create.
An empty value lists the available channels.
Channels names ending in ! are private. They can be joined by anyone that
knows they exist, but will not be listed in the channel listings. To return
to the main/default channel, simply switch channels to 'gab':
gab channel gab
Examples:
gab msg "Good afternoon!"
gab list 20
gab block annoyingperson
gab channel my-secret-channel!
gab channel a-public-channel
gab unblock somedude
"""
title = "\033[1mGAB v2.1\033[0m"
def get_chan():
@ -15,10 +44,13 @@ def get_chan():
fp = "/home/{}/.gab_chan".format(current_user)
if not os.path.isfile(fp):
return "gab"
return ""
with open(fp, 'r') as chanfile:
return chanfile.read().split("\n")[0]
channel = chanfile.read().split("\n")[0].strip()
if channel:
channel = "-" + channel
return channel
def blocked_users():
current_user = os.environ.get('USER')
@ -30,8 +62,20 @@ def blocked_users():
with open(fp, 'r') as blockfile:
return blockfile.read().split("\n")
def get_files():
return [[x, "/home/{}/.{}".format(x, get_chan())] for x in os.listdir("/home/") if x not in blocked_users()]
def get_files(channel):
return [[x, "/home/{}/.gab{}".format(x, channel)] for x in os.listdir("/home/") if x not in blocked_users()]
def list_channels():
user_dirs = ["/home/{}".format(x) for x in os.listdir("/home/")]
chans = {"gab"}
for x in user_dirs:
for y in os.listdir(x):
if len(y) > 5 and y[:5] == ".gab-" and y[-1] != "!":