diff --git a/komrade/cli/cli.py b/komrade/cli/cli.py index 6ff6d88..51f088b 100644 --- a/komrade/cli/cli.py +++ b/komrade/cli/cli.py @@ -395,15 +395,18 @@ class CLI(Logger): self.help() - def post(self,dat=''): + def post(self,dat='',maxlen=MAX_POST_LEN): if self.with_required_login(): self.stat(f'Write your post below. Maximum of 1000 characters.', 'Press Ctrl+D to complete, or Ctrl+C to cancel.') print() - msg_s = multiline_input().strip() + msg_s = multiline_input() #.strip() if not msg_s: print('\n') self.stat('Not sending. No text entered.') return + if len(msg_s)>maxlen: + self.stat(f'Not sending. Message is {len(msg_s)-maxlen} over the character limit of {maxlen}.\n\nThe message you wanted to send was (in case you want to copy/paste it to edit it):\n\n{msg_s}') + return self.log(f'Post written: {msg_s}') msg_obj = self.komrade.post( diff --git a/komrade/constants.py b/komrade/constants.py index fb1b8f2..d7b1b8d 100644 --- a/komrade/constants.py +++ b/komrade/constants.py @@ -168,3 +168,6 @@ CLI_TITLE = 'KOMRADE' CLI_FONT = 'clr5x6'#'colossal' CLI_WIDTH = STATUS_LINE_WIDTH = 60 + +MAX_POST_LEN = 1000 +MAX_MSG_LEN = 1000 \ No newline at end of file