Context
Context is an interface which provides next methods:
TelegramClient getTelegramClient()- get implementation ofTelegramClientvoid setTelegramClient(TelegramClient)Update getUpdate()- get current updateContext createNewContext(TelegramClient, Update)
update { // this closure delegated to MethodsContext getTelegramClient() // or simply `telegramClient` getUpdate() // or simply `update` // etc.. } message(~/mesg/) { getMatcher() // or simply `matcher` } 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())