/
tgo.go
52 lines (52 loc) · 1.34 KB
/
tgo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// TGO is a simple, flexible, and fully featured telegram-bot-api framework for Go developers.
//
// It gives you the ability to implement your own filters, middlewares, and even routers!
//
// All API methods and types are all code generated from the [telegram's documentation] in `./cmd` at the `api.gen.go` file.
//
// Example:
//
// package main
//
// import (
// "fmt"
// "log"
// "time"
//
// "github.com/haashemi/tgo"
// "github.com/haashemi/tgo/filters"
// "github.com/haashemi/tgo/routers/message"
// )
//
// const BotToken = "bot_token"
//
// func main() {
// bot := tgo.NewBot(BotToken, tgo.Options{ DefaultParseMode: tgo.ParseModeHTML })
//
// info, err := bot.GetMe()
// if err != nil {
// log.Fatalln("Failed to fetch the bot info", err.Error())
// }
//
// mr := message.NewRouter()
// mr.Handle(filters.Command("start", info.Username), Start)
// bot.AddRouter(mr)
//
// for {
// log.Println("Polling started as", info.Username)
//
// if err := bot.StartPolling(30, "message"); err != nil {
// log.Fatalln("Polling failed >>", err.Error())
// time.Sleep(time.Second * 5)
// }
// }
// }
//
// func Start(ctx *message.Context) {
// text := fmt.Sprintf("Hi <i>%s</i>!", ctx.Message.From.FirstName)
//
// ctx.Reply(&tgo.SendMessage{Text: text})
// }
//
// [telegram's documentation]: https://core.telegram.org/bots/api
package tgo