lib/rrimm/publisher/reddit.rb in rrimm-0.14.1 vs lib/rrimm/publisher/reddit.rb in rrimm-0.14.3

- old
+ new

@@ -14,11 +14,11 @@ end attr_reader :subreddits def feed2sr(feed) - "rss_#{feed.title.gsub(/[\. ]+/, '')}"[0.20] + "rss_#{feed.title.gsub(/[\. ]+/, '')}"[0..20] end def publish(input, feed, item) subreddit = subreddits[feed.title] || check_subreddit!(feed) subreddits[feed.title] = subreddit @@ -70,9 +70,18 @@ type: "public", wiki_edit_age: 0, wiki_edit_karma: 100, wikimode: 'disabled' ) + rescue Redd::APIError => e + if e.message =~ /doing that too much.*again in (.*) minutes/ + delay = $1.to_i + 1 + puts "API limit for subreddit creation reached, wait #{delay} minutes" + sleep(delay * 60) + retry + else + raise + end end def sr(name) reddit.subreddit(name) end