Browse Source

fixed bug before ~/.gab_chan exists, and added line to -h help text.

channels-redux
cmccabe 3 years ago
parent
commit
83edcd37e5
  1. 12
      gab

12
gab

@ -4,7 +4,7 @@ import sys
import time
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"
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"
title = "\033[1mGAB v2.1\033[0m"
def get_chan():
@ -26,7 +26,7 @@ def blocked_users():
with open(fp, 'r') as blockfile:
return blockfile.read().split("\n")
chan = get_chan()
files = [[x, "/home/{}/.{}".format(x, get_chan())] for x in os.listdir("/home/") if x not in blocked_users()]
@ -170,14 +170,16 @@ def unblock_user(user_to_unblock):
print("User '{}' has been removed from your block list".format(user_to_unblock))
def switch_channel(chan):
def switch_channel(newchan):
current_user = os.environ.get('USER')
fp = "/home/{}/.gab_chan".format(current_user)
with open(fp, 'w') as chanfile:
chanfile.write(chan)
chanfile.write(newchan)
print("You are now viewing the '{}' channel.".format(chan))
global chan
chan = newchan
print("You are now viewing the '{}' channel.".format(newchan))
list_messages()

Loading…
Cancel
Save