Skip to content

devalecs/tgbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pluggable Telegram bot written in Golang

Travis GoDoc

Plugin example

package main

import (
	"gopkg.in/devalecs/tgbot.v1"
	"gopkg.in/devalecs/tgo.v1"
)

type PingPlugin struct{}

func (p *PingPlugin) Reply(b tgbot.B, update *tgo.Update) {
	b.SendMessage(tgo.SendMessageParams{
		ChatID: update.Message.Chat.ID,
		Text:   "pong",
	})
}

func (p *PingPlugin) Match(b tgbot.B, update *tgo.Update) bool {
	return b.MessageTextMatch(update, "ping")
}

func (p *PingPlugin) Settings() tgbot.PluginSettings {
	return tgbot.PluginSettings{
		Help: "*/ping*: Sample ping pong plugin",
	}
}

Bot example

package main

import (
	"log"

	"gopkg.in/devalecs/tgbot.v1"
)

func main() {
	b := tgbot.NewBot(tgbot.Config{
		Token: "yourBotAPIToken",
	})

	b.RegisterPlugins(
		new(PingPlugin),
	)

	err := b.Start()
	if err != nil {
		log.Fatal(err)
	}
}

About

Pluggable Telegram bot written in Golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages