Skip to content
Camilo A. Sampedro Restrepo edited this page Jun 28, 2016 · 3 revisions

Welcome to the telegrambot4s wiki!

Here will be listed some use cases of the library.

Bot object

First of all, creating a bot object:

import info.mukel.telegrambot4s._, api._, methods._, models._, Implicits._
object MyBot extends TelegramBot with Polling with Commands {
  def token = "your-token"
}

Handling messages

Override handleMessage from TelegramBot. You have then a Message object with all the information needed to answer the users.

override def handleMessage(message: Message) = message.text match {
  case Some(text) => api.request(SendMessage(message.chat.id, text))
  case _ => println("It had not a text")
}

Handling inline queries

Override handleInlineQuery from TelegramBot.

override def handleInlineQuery(inlineQuery: InlineQuery) = {
  api.request(AnswerInlineQuery(inlineQuery.id,Seq(new InlineQueryResultCachedSticker("0","sticker-file_id"))))
}

Clone this wiki locally