Class: SinatraListener

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/post2irc/sinatra_listener.rb

Constant Summary collapse

UNAUTHORIZED =
[ 401, 'unauthorized']

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.start(bind = '0.0.0.0', port = '4567', token = 'public') ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/post2irc/sinatra_listener.rb', line 5

def self.start(bind='0.0.0.0',port='4567',token='public')
  @@token = token
  configure :production, :development do
    enable :logging
    set :port, port
    set :bind, bind
  end
  self.run!
end

Instance Method Details

#authorized?(prefix) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/post2irc/sinatra_listener.rb', line 20

def authorized?(prefix)
  @@token == prefix
end

#string_cleaner(message) ⇒ Object



15
16
17
18
# File 'lib/post2irc/sinatra_listener.rb', line 15

def string_cleaner(message)
    #remove all non printable characters and replace with a dot
    message.gsub /[^[:print:]]/m, "."
end

#talk(service, parts) ⇒ Object



24
25
26
27
# File 'lib/post2irc/sinatra_listener.rb', line 24

def talk(service, parts)
  parts.insert(0,service)
  Ircbot.report string_cleaner( parts.compact.join(' :: ') )
end