Context

Context is an interface which provides next methods:

  • TelegramClient getTelegramClient() - get implementation of TelegramClient
  • void setTelegramClient(TelegramClient)
  • Update getUpdate() - get current update
  • Context createNewContext(TelegramClient, Update)

MethodsContext

update { // this closure delegated to MethodsContext getTelegramClient() // or simply `telegramClient` getUpdate() // or simply `update` // etc.. } 

MessageContext

message(~/mesg/) { getMatcher() // or simply `matcher` } 

CommandContext

command(~/echo/, ~/(.+)/) { getMatcher() // or simply `matcher` getArgsMatcher() getArgsText() } 
import tech.teslex.telegroo.api.context.MethodsContext import tech.teslex.telegroo.simple.update.SimpleCommandUpdateHandler import tech.teslex.telegroo.simple.SimpleTelegroo import java.util.regex.Pattern class StartCommandHandler implements SimpleCommandUpdateHandler {	Pattern pattern = ~/start/ void handle(MethodsContext context) {	context.sendMessage {	text = 'Welcome!' } } } def bot = new SimpleTelegroo('TOKEN') bot.commandUpdateHandler(new StartCommandHandler())