Bad title, but I dont know how to describe it.
on :message, "\.addfact" do |m|
open('facts.txt', 'a') { |f|
f.print "\n *XXXXXX* ~ #{m.user.nick}"
}
m.reply "Fact added, #{m.user.nick}"
end
Basically, whenever someone in the IRC channel the bot is on does this:
<random_irc_user>.addfact This is a fact. But it includes dots ... , and smileys =) :)
the little bot here is gonna append it to a text file, with the formatting
This is another fact but its on an other line and was added earlier =) ~ Cool_guy
This is a fact, it includes dots ... , and smileys =) :) ~ random_irc_user
I've got the new line, and "random_irc_user" part working, but i have no idea how to do the actual fact. I guess arguments or similar but I'm not really sure about them.
Use a regular expression and capture everything after your command:
on :message, /^\.addfact (.+)/ do |m, fact|
File.open('facts.txt', 'a') { |f| f.puts "#{fact} ~ #{m.user.nick}" }
m.reply "Fact added!"
end