Skip to content

gohouse/gotgbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoTgBot

telegram bot api with golang

demo

package main

import (
	tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
	"github.com/gohouse/gotgbot"
	"github.com/gohouse/gotgbot/bot"
	"strings"
)

func main() {
	var token = "1323450187:xxxxxxxxxxxxxxxxxxxxxxxx"
	r := gotgbot.Default(token)

	r.GET("/help", func(ctx *bot.Context) {
		ctx.BotAPI.Send(tgbotapi.NewMessage(ctx.Update.Message.Chat.ID, strings.Join(r.BuildHelpList(bot.String2ModuleType(ctx.Update.Message.Chat.Type)), "\n")))
	}).SetTitle("命令列表查看")

	r.GET("/start", Start)
	r.GET("/test", Start)
	r.GET("/aaa", Start)

	r.Run()
	//r.RunWebhook()
}
func Start(ctx *bot.Context) {
	ctx.Send(tgbotapi.NewMessage(ctx.Update.Message.Chat.ID, "欢迎光临,发送 /help 命令解锁更多操作"))
}

About

telegram bot api with golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages