irc-bots/coin_flip_bot/flip-a-coin.rb

34 lines
662 B
Ruby

# coding: utf-8
require 'cinch'
bot = Cinch::Bot.new do
configure do |c|
c.nick = 'MrRollBot'
c.server = 'irc.guava.space'
c.port = 6697
c.channels = ['#bot-test', '#chat']
c.ssl.use = true
end
on :message, /^!roll/ do |m|
random_int = rand(0..100).to_s
m.params[1].match /^!roll ([0-9]*)-([0-9]*)/ do |numbers|
if not numbers[1].nil? then
random_int = rand(numbers[1].to_i..numbers[2].to_i).to_s
end
end
m.reply random_int
end
on :message, /!coin/ do |m|
probs = rand(1..10).to_i
if probs < 5 then
m.reply "Heads"
else
m.reply "Tails"
end
end
end
bot.start