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

34 lines
662 B
Ruby
Raw Normal View History

2017-12-14 22:47:33 +00:00
# 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