Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
akurilov committed Sep 20, 2023
1 parent 0a814a5 commit d108536
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion api/telegram/sub.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
package telegram

import (
"errors"
"fmt"
"gopkg.in/telebot.v3"
"strings"
)

var ErrCreateSubNoArgs = errors.New("not enough arguments to create a text subscription")

func CreateTextSubscription(ctx telebot.Context) (err error) {
fmt.Printf("TODO: created, sub id is XXX\n")
txt := ctx.Text()
args, ok := strings.CutPrefix(txt, "/sub ")
if !ok {
err = ErrCreateSubNoArgs
}
if err == nil {
fmt.Printf("Create a text subscription with args: %s\n", args)
}
return
}
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func main() {
HasCustomCert: true,
Listen: fmt.Sprintf(":%d", cfg.Api.Port),
},
ParseMode: telebot.ModeMarkdownV2,
}
var b *telebot.Bot
b, err = telebot.NewBot(s)
Expand Down

0 comments on commit d108536

Please sign in to comment.