end\r
\r
def rewatch_rss(m=nil, params=nil)\r
- stop_watches\r
+ if params and handle = params[:handle]\r
+ feed = @feeds.fetch(handle.downcase, nil)\r
+ if feed\r
+ @bot.timer.reschedule(@watch[feed.handle], 0)\r
+ m.okay if m\r
+ else\r
+ m.reply _("no such feed %{handle}") % { :handle => handle } if m\r
+ end\r
+ else\r
+ stop_watches\r
\r
- # Read watches from list.\r
- watchlist.each{ |handle, feed|\r
- watchRss(feed, m)\r
- }\r
- m.okay if m\r
+ # Read watches from list.\r
+ watchlist.each{ |handle, feed|\r
+ watchRss(feed, m)\r
+ }\r
+ m.okay if m\r
+ end\r
end\r
\r
private\r
return seconds\r
end\r
\r
+ def select_nonempty(*ar)\r
+ debug ar\r
+ ret = ar.map { |i| (i && i.empty?) ? nil : i }.compact.first\r
+ (ret && ret.empty?) ? nil : ret\r
+ end\r
+\r
def printFormattedRss(feed, item, opts=nil)\r
debug item\r
places = feed.watchers\r
# limit to 160 characters, and most of them are under 140 characters\r
tit_opt[:limit] = @bot.config['rss.head_max'] unless feed.type == 'twitter'\r
\r
- title = "#{Bold}#{item.title.to_s.ircify_html(tit_opt)}#{Bold}" if item.title\r
+ if item.title\r
+ base_title = item.title.to_s.dup\r
+ # git changesets are SHA1 hashes (40 hex digits), way too long, get rid of them, as they are\r
+ # visible in the URL anyway\r
+ # TODO make this optional?\r
+ base_title.sub!(/^Changeset \[([\da-f]{40})\]:/) { |c| "(git commit)"} if feed.type = 'trac'\r
+ title = "#{Bold}#{base_title.ircify_html(tit_opt)}#{Bold}"\r
+ end\r
\r
desc_opt = {\r
:limit => @bot.config['rss.text_max'],\r
\r
link = item.link.href rescue item.link.chomp rescue nil\r
\r
- category = item.category.content rescue item.dc_subject rescue nil\r
- category = nil if category and category.empty?\r
- author = item.author.name.content rescue item.dc_creator rescue item.author rescue nil\r
- author = nil if author and author.empty?\r
+ category = select_nonempty((item.category.content rescue nil), (idem.dc_subject rescue nil))\r
+ author = select_nonempty((item.author.name.content rescue nil), (item.dc_creator rescue nil), (item.author rescue nil))\r
\r
line1 = nil\r
line2 = nil\r
\r
case feed.type\r
when 'blog'\r
- author << " " if author\r
+ author += " " if author\r
abt = category ? "about #{category} " : ""\r
line1 = "#{handle}#{date}#{author}blogged #{abt}at #{link}"\r
line2 = "#{handle}#{title} - #{desc}"\r
+ when 'git'\r
+ author += " " if author\r
+ line1 = "#{handle}#{date}#{author}commited #{title} @ #{link}"\r
when 'forum'\r
line1 = "#{handle}#{date}#{title}#{at}#{link}"\r
when 'wiki'\r
line1 = "#{handle}#{date}Message #{title} sent by #{author}. #{desc}"\r
when 'trac'\r
line1 = "#{handle}#{date}#{title} @ #{link}"\r
- unless item.title =~ /^Changeset \[(\d+)\]/\r
+ unless item.title =~ /^(?:Changeset \[(?:[\da-f]+)\]|\(git commit\))/\r
line2 = "#{handle}#{date}#{desc}"\r
end\r
when '/.'\r
:action => 'unwatch_rss'\r
plugin.map 'rss rmwatch :handle [in :chan]',\r
:action => 'unwatch_rss'\r
-plugin.map 'rss rewatch',\r
+plugin.map 'rss rewatch [:handle]',\r
:action => 'rewatch_rss'\r