Last active
December 15, 2015 14:29
-
-
Save maxjustus/5274618 to your computer and use it in GitHub Desktop.
A campfire bot that speaks the posts aloud. A unique voice is given to each user based on their name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'tinder' | |
require 'time' | |
campfire = Tinder::Campfire.new 'subdomain', :token => 'herp' | |
VOICES = [ | |
'Agnes', | |
'Albert', | |
'Alex', | |
'Bad News', | |
'Bahh', | |
'Bells', | |
'Boing', | |
'Bruce', | |
'Bubbles', | |
'Cellos', | |
'Deranged', | |
'Fred', | |
'Good News', | |
'Hysterical', | |
'Junior', | |
'Kathy', | |
'Pipe Organ', | |
'Princess', | |
'Ralph', | |
'Trinoids', | |
'Vicki', | |
'Victoria', | |
'Whisper', | |
'Zarvox', | |
] | |
loop do | |
begin | |
campfire.find_room_by_id('440273').listen do |message| | |
if message[:user] | |
unique_voice_id = message[:user][:name].each_byte.reduce(0){|t,n| t+n} % VOICES.length | |
voice = VOICES[unique_voice_id] | |
message = "#{message[:body].to_s.gsub(/[^\w| ]*/, '').gsub(/(\[|\().*?(\]|\))|http.*( |$)/, '')}" | |
spawn "say", "-v#{voice}", message | |
end | |
end | |
rescue => e | |
p e | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment