Class: Lita::Handlers::Boardgamegeek

Inherits:
Handler
  • Object
show all
Defined in:
lib/lita/handlers/boardgamegeek.rb

Instance Method Summary collapse

Instance Method Details

#game_id(name) ⇒ Object



14
15
16
17
18
# File 'lib/lita/handlers/boardgamegeek.rb', line 14

def game_id(name)
  bgg = BggApi.new
  result = bgg.search(query: name, type: 'boardgame')
  result["item"].first["id"]
end

#search(response) ⇒ Object



8
9
10
11
12
# File 'lib/lita/handlers/boardgamegeek.rb', line 8

def search(response)
  term = response.match_data[1]
  id = game_id(term)
  response.reply "#{term}: http://www.boardgamegeek.com/boardgame/#{id}"
end