Skip to content

top-tl/telebot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

toptl-telebot

telebot (Go) plugin for TOP.TL — automatically post bot stats and check user votes.

Installation

go get github.com/top-tl/telebot

Usage

package main

import (
    "log"
    "time"

    toptl "github.com/top-tl/go"
    toptltelebot "github.com/top-tl/telebot"
    tele "gopkg.in/telebot.v3"
)

func main() {
    bot, _ := tele.NewBot(tele.Settings{
        Token:  "BOT_TOKEN",
        Poller: &tele.LongPoller{Timeout: 10 * time.Second},
    })

    client := toptl.New("your-toptl-token")
    plugin := toptltelebot.New(client, "my_bot")
    defer plugin.Stop()

    bot.Use(plugin.Middleware())

    bot.Handle("/voted", func(c tele.Context) error {
        voted, _ := plugin.HasVoted(c, c.Sender().ID)
        if voted {
            return c.Send("Thanks for voting!")
        }
        return c.Send("Please vote at https://top.tl/my_bot")
    })

    bot.Start()
}

License

MIT

About

telebot (Go) plugin for TOP.TL — auto-post bot stats & check votes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages