Users can write messages from their $EDITOR

channel-indicator
gogoigo 3 years ago
parent cdba3d876f
commit 3015539fc4
  1. 16
      gab

16
gab

@ -3,6 +3,10 @@ import os
import sys
import time
from datetime import datetime
import subprocess as sp
from subprocess import call
import tempfile
chan_dir = ".config/gab/channels" ## not used yet. todo: move all gab channel logs to this dir
log = {}
@ -37,7 +41,7 @@ Examples:
gab unblock somedude
"""
title = "\033[1mGAB v2.1\033[0m"
title = "\033[1mGAB v2.2\033[0m"
def get_chan():
current_user = os.environ.get('USER')
@ -245,7 +249,15 @@ def parse_command():
print("Invalid command input to 'list'")
elif args[0] in ["-m", "--msg", "msg"]:
if len(args) < 2:
print("Expected a message, but one was not received")
# code from https://stackoverflow.com/a/6309753
EDITOR = os.environ.get('EDITOR') if os.environ.get('EDITOR') else 'nano'
with tempfile.NamedTemporaryFile(suffix=".tmp") as tf:
tf.flush()
call([EDITOR, tf.name])
tf.seek(0)
edited_message = tf.read()
add_message(edited_message.decode("utf-8") )
elif len(args) > 2:
print("Expected a message, but received too many arguments. Did you put your message in quotes?")
else:

Loading…
Cancel
Save