Skip to content

Latest commit

 

History

History
34 lines (27 loc) · 793 Bytes

readme.md

File metadata and controls

34 lines (27 loc) · 793 Bytes

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 命令解锁更多操作"))
}