Browse Source

Fixes errors while blocking

action-support
sloum 3 years ago
parent
commit
78981d514e
  1. 28
      gab

28
gab

@ -6,6 +6,19 @@ from datetime import datetime
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"
title = "\033[1mGAB v2.1\033[0m"
def blocked_users():
current_user = os.environ.get('USER')
fp = "/home/{}/.gab_block".format(current_user)
if not os.path.isfile(fp):
return []
with open(fp, 'r') as blockfile:
return blockfile.read().split("\n")
files = [[x, "/home/{}/.gab".format(x)] for x in os.listdir("/home/") if x not in blocked_users()]
log = {}
@ -121,30 +134,19 @@ def unblock_user(user_to_unblock):
print("You do not have any users on your block list, no action taken")
return
if not os.path.isdir(block_fp):
if not os.path.isdir(unblock_fp):
print("User '{}' does not exist, no action taken".format(user_to_unblock))
return
blocked_users_list = [x for x in blocked_users() if x != user_to_unblock]
with open(fp, 'w') as blocked:
fp.write("\n".join(blocked_users_list))
blocked.write("\n".join(blocked_users_list))
print("User '{}' has been removed from your block list".format(user_to_unblock))
def blocked_users():
current_user = os.environ.get('USER')
fp = "/home/{}/.gab_block".format(current_user)
if not os.path.isfile(fp):
return []
with open(fp, 'r') as blockfile:
return blockfile.read().split("\n")
def parse_command():
args = sys.argv[1:]
if not len(args):

Loading…
Cancel
Save