From e3db8d4ee4eaadfbfb7f2d1c8bdfb8b752df5e8c Mon Sep 17 00:00:00 2001 From: Tobin Date: Wed, 1 Apr 2015 13:20:18 -0500 Subject: [PATCH] properly strip subreddit name and post submission --- rtv/subreddit.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rtv/subreddit.py b/rtv/subreddit.py index f57a989..4559476 100644 --- a/rtv/subreddit.py +++ b/rtv/subreddit.py @@ -1,6 +1,7 @@ import curses import time import requests +import praw from .exceptions import SubredditError from .page import BasePage, Navigator, BaseController @@ -102,6 +103,10 @@ class SubredditPage(BasePage): show_notification(self.stdscr, ['Can\'t post to a multireddit']) return + name = name.strip(' /') # Strip leading and trailing backslashes + if name.startswith('r/'): + name = name[2:] + # Open the submission window submission_info = SUBMISSION_FILE.format(name=name) curses.endwin() @@ -114,7 +119,7 @@ class SubredditPage(BasePage): return try: title, content = submission_text.split('\n', 1) - show_notification(self.stdscr, [title]) + self.reddit.submit(name, title, text=content) except praw.errors.APIException as e: show_notification(self.stdscr, [e.message]) else: