Cat bot
This commit is contained in:
commit
b28822b0bb
33
bot.rb
Normal file
33
bot.rb
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
require 'cinch'
|
||||||
|
|
||||||
|
|
||||||
|
file = File.open "cat_facts.html", "r"
|
||||||
|
a = file.read.split "<li"
|
||||||
|
l = a.collect do |s|
|
||||||
|
if s.include? "id"
|
||||||
|
s.slice s.index("id"), s.index("<sub>")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
l.delete_at 0
|
||||||
|
done = l.collect do |s|
|
||||||
|
if s.include? "id"
|
||||||
|
s.slice( s.index(">") + 1 .. s.index("<") - 1 )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
bot = Cinch::Bot.new do
|
||||||
|
configure do |c|
|
||||||
|
c.nick = 'CatFacts^'
|
||||||
|
c.server = 'server'
|
||||||
|
c.port = port
|
||||||
|
c.channels = ['#bot-test']
|
||||||
|
c.ssl.use = true
|
||||||
|
end
|
||||||
|
|
||||||
|
on :message, /(?i)(.*).*cat.*/ do |m|
|
||||||
|
m.reply done.sample
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
bot.start
|
5
cat_facts.html
Normal file
5
cat_facts.html
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user