Skip to content

Instantly share code, notes, and snippets.

@maxjustus
Last active December 15, 2015 14:29
Show Gist options
  • Save maxjustus/5274618 to your computer and use it in GitHub Desktop.
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.
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