Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
Alexander Yakovlev | 81321d07df |
5
bot.rb
5
bot.rb
|
@ -2,6 +2,7 @@ require 'cinch'
|
|||
require 'cinch-dicebag'
|
||||
require_relative 'plugins/link_info'
|
||||
require_relative 'plugins/help'
|
||||
require_relative 'plugins/rss'
|
||||
|
||||
def translit (text)
|
||||
table = {
|
||||
|
@ -65,8 +66,8 @@ bot = Cinch::Bot.new do
|
|||
configure do |c|
|
||||
c.server = "irc.forestnet.org"
|
||||
c.port = 6667
|
||||
c.channels = ["#urq", "#instead", "#qsp", "#ifrus"]
|
||||
c.nick = 'XyZ'
|
||||
c.channels = ["#urq", "#ifrus"]
|
||||
c.nick = 'Попугай'
|
||||
c.plugins.plugins = [
|
||||
Cinch::Plugins::Dicebag,
|
||||
Cinch::Help,
|
||||
|
|
35
plugins/rss.rb
Normal file
35
plugins/rss.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
require 'rss'
|
||||
require 'yaml'
|
||||
|
||||
class RssEmitter
|
||||
def initialize(bot)
|
||||
@bot = bot
|
||||
end
|
||||
def start
|
||||
cache = YAML.load_file('cache.yml')
|
||||
while true
|
||||
sleep 10
|
||||
cache.each do |feed|
|
||||
rss = RSS::Parser.parse(feed.url)
|
||||
rss.items.each do |item|
|
||||
if item.date > feed.date then
|
||||
@send_link(rss, item)
|
||||
end
|
||||
end
|
||||
end
|
||||
File.write('cache.yml', cache.to_yaml)
|
||||
end
|
||||
end
|
||||
def send_link(rss, item)
|
||||
@bot.handlers.dispatch(:rss, rss.channel.title, item.link)
|
||||
end
|
||||
end
|
||||
|
||||
class Rss
|
||||
include Cinch::Plugin
|
||||
|
||||
listen_to :rss
|
||||
def listen(m, title, link)
|
||||
print "#{title}: #{link}"
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue