-
Notifications
You must be signed in to change notification settings - Fork 0
/
stickers.go
56 lines (46 loc) · 1.32 KB
/
stickers.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
53
54
55
56
package main
import (
"fmt"
tg "gopkg.in/telebot.v3"
)
// Populate Stickers
func populateStickers(owner tg.Recipient, bot tg.Bot, path string, stickerPackName string) error {
for _, sticker := range stickersData.Stickers {
file := tg.FromDisk(fmt.Sprintf("%s/%s", cfg.PathToStickers, sticker.File))
png, err := bot.UploadSticker(owner, &file)
if err != nil {
return err
}
stickerSet := tg.StickerSet{
Name: stickerPackName,
PNG: png,
Emojis: sticker.Emojis,
}
err = bot.AddSticker(owner, stickerSet)
if err != nil {
return err
}
}
return nil
}
// Create StickerPack
func createStickerPack(owner tg.Recipient, bot tg.Bot, stickerPackName string) error {
file := tg.FromDisk(fmt.Sprintf("%s/%s", cfg.PathToStickers, stickersData.Headsticker.File))
png, err := bot.UploadSticker(owner, &file)
if err != nil {
return err
}
stickerSet := tg.StickerSet{
Name: stickerPackName,
Title: stickersData.Packtitle,
Thumbnail: &tg.Photo{File: tg.FromDisk(fmt.Sprintf("%s/%s", cfg.PathToStickers, stickersData.Thumbnail.File)), Width: 100, Height: 100},
PNG: png,
Emojis: fmt.Sprintf("%s/%s", cfg.PathToStickers, stickersData.Headsticker.Emojis),
}
err = bot.CreateStickerSet(owner, stickerSet)
if err != nil {
return err
}
bot.AddSticker(owner, stickerSet)
return nil
}