🔀 Merge branch 'develop'
This commit is contained in:
commit
ebfabb48be
|
@ -2,7 +2,8 @@
|
|||
I develop this project in my spare time, and I do it and I will do it free of charge. However, you can make a donation or become a sponsor to make sure that I have enough coffee and pizza for night coding.
|
||||
|
||||
**These people sponsored current version of the project:**
|
||||
- Yami Odymel
|
||||
- Daniil Tlenov
|
||||
- Aurielb
|
||||
- MoD21k
|
||||
- Daniil Tlenov
|
||||
- @kirillDanshin
|
||||
- MoD21k
|
||||
- @YamiOdymel
|
|
@ -12,11 +12,11 @@ button_share:
|
|||
button_add_sticker:
|
||||
other: ➕ Add sticker
|
||||
button_add_pack:
|
||||
other: 📦 Add pack
|
||||
other: 📦 Add set
|
||||
button_del_sticker:
|
||||
other: 🗑 Delete sticker
|
||||
button_del_pack:
|
||||
other: 🗑 Delete pack
|
||||
other: 🗑 Delete set
|
||||
button_reset:
|
||||
other: 🔥 Reset pack
|
||||
button_cancel:
|
|
@ -1,11 +1,11 @@
|
|||
cancel_add_sticker:
|
||||
other: You cancelled the process of adding a new stickers to your pack.
|
||||
cancel_add_pack:
|
||||
other: You cancelled the process of adding a new packs to yours.
|
||||
other: You cancelled the process of adding a new sets to your pack.
|
||||
cancel_del_sticker:
|
||||
other: You cancelled the process of removing a stickers from your pack.
|
||||
cancel_del_pack:
|
||||
other: You cancelled the process of removing a sticker packs from yours.
|
||||
other: You cancelled the process of removing a sets from your pack.
|
||||
cancel_reset:
|
||||
other: You cancelled the process of reseting your stickers pack.
|
||||
cancel_error:
|
|
@ -1,17 +1,17 @@
|
|||
error_already_add_sticker:
|
||||
other: This sticker is already in your pack.
|
||||
error_already_add_pack:
|
||||
other: All stickers from *{{.SetTitle}}* pack is already in yours.
|
||||
other: All stickers from *{{.SetTitle}}* set is already in yours.
|
||||
error_already_del_sticker:
|
||||
other: Maybe this sticker is already removed from your pack.
|
||||
error_already_del_pack:
|
||||
other: Maybe this pack is already removed from yours.
|
||||
other: Maybe this set is already removed from your pack.
|
||||
error_already_reset:
|
||||
other: There is nothing to reset, pack is already empty.
|
||||
error_reset_phrase:
|
||||
other: Invalid phrase of resetting. This action has been canceled.
|
||||
error_empty_del:
|
||||
other: There is nothing to remove, pack is empty.
|
||||
other: There is nothing to remove, your pack is empty.
|
||||
error_empty_add_pack:
|
||||
other: You try to add a sticker that exists outside the packs. Use /{{.AddStickerCommand}} instead.
|
||||
error_unknown:
|
|
@ -1,12 +1,12 @@
|
|||
reply_start:
|
||||
other: |
|
||||
Hello, I'm the [@{{.Username}}](tg://user?id={{.ID}})!
|
||||
I can create your personal pack with stickers from others packs.
|
||||
I can create your personal stickers pack with stickers from others sets.
|
||||
Without limits and installing. In any chat. For free.
|
||||
reply_add_sticker:
|
||||
other: Send an existing stickers from any other packs to add it to yourself.
|
||||
other: Send an existing stickers from any other sets to add it to your pack.
|
||||
reply_add_pack:
|
||||
other: Send an existing stickers from any other packs to add the entire packs to yourself.
|
||||
other: Send an existing stickers from any other sets to add the entire sets to your pack.
|
||||
reply_del_sticker:
|
||||
other: Send an existing stickers from your pack for removing it.
|
||||
reply_del_pack:
|
||||
|
@ -20,7 +20,7 @@ reply_reset:
|
|||
reply_help:
|
||||
other: |
|
||||
/{{.AddStickerCommand}} - add a single sticker to your pack
|
||||
/{{.AddPackCommand}} - add a full other pack to your pack
|
||||
/{{.AddPackCommand}} - add a full stickers set to your pack
|
||||
/{{.DeleteStickerCommand}} - remove a single sticker from your pack
|
||||
/{{.DeletePackCommand}} - remove a sticker set from your pack
|
||||
/{{.ResetCommand}} - remove all stickers from your pack
|
18
init/init.go
18
init/init.go
|
@ -5,14 +5,24 @@ import (
|
|||
"github.com/toby3d/MyPackBot/internal/bot"
|
||||
"github.com/toby3d/MyPackBot/internal/config"
|
||||
"github.com/toby3d/MyPackBot/internal/db"
|
||||
"github.com/toby3d/MyPackBot/internal/errors"
|
||||
"github.com/toby3d/MyPackBot/internal/i18n"
|
||||
)
|
||||
|
||||
// init prepare configuration and other things for successful start
|
||||
func init() {
|
||||
log.Ln("Initializing...")
|
||||
i18n.Open("translations/") // Preload localization strings
|
||||
config.Open("configs/config.yaml") // Preload configuration file
|
||||
db.Open("stickers.db") // Open database or create new one
|
||||
bot.New() // Create bot with credentials from config
|
||||
|
||||
// Preload localization strings
|
||||
err := i18n.Open("i18n/")
|
||||
errors.Check(err)
|
||||
|
||||
// Preload configuration file
|
||||
config.Open("configs/config.yaml")
|
||||
|
||||
// Open database or create new one
|
||||
db.Open("stickers.db")
|
||||
|
||||
// Create bot with credentials from config
|
||||
bot.New()
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
tg "github.com/toby3d/telegram"
|
||||
)
|
||||
|
||||
// Bot is a main object of Telegram bot
|
||||
var Bot *tg.Bot
|
||||
|
||||
// New just create new bot by configuration credentials
|
||||
|
|
|
@ -6,7 +6,10 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
Config *config.Config
|
||||
// Config is a main object of preloaded configuration YAML
|
||||
Config *config.Config
|
||||
|
||||
// ChannelID is a announcements channel ID
|
||||
ChannelID int64
|
||||
)
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/toby3d/MyPackBot/internal/errors"
|
||||
)
|
||||
|
||||
// DB is a main object of current database connection
|
||||
var DB *buntdb.DB
|
||||
|
||||
// Open just open connection to database for work
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/tidwall/buntdb"
|
||||
)
|
||||
|
||||
// Users return array of all avaliable UserID in database
|
||||
// Users return array of all available UserID in database
|
||||
func Users() ([]int, error) {
|
||||
var users []int
|
||||
err := DB.View(func(tx *buntdb.Tx) error {
|
||||
|
|
|
@ -8,8 +8,10 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
// WaitForwards is a wait group which wait send all announcements before panic
|
||||
WaitForwards = new(sync.WaitGroup)
|
||||
sysLogger *syslog.Writer
|
||||
|
||||
sysLogger *syslog.Writer
|
||||
)
|
||||
|
||||
// Check helps debug critical errors without warnings from 'gocyclo' linter
|
||||
|
@ -20,7 +22,11 @@ func Check(err error) {
|
|||
// Wait what all users get announcement message first
|
||||
WaitForwards.Wait()
|
||||
|
||||
sysLogger.Crit(err.Error())
|
||||
err = sysLogger.Crit(err.Error())
|
||||
if err != nil {
|
||||
log.Panicln(err.Error())
|
||||
}
|
||||
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package models
|
|||
|
||||
import tg "github.com/toby3d/telegram"
|
||||
|
||||
// Commands... represents available and supported bot commands
|
||||
const (
|
||||
CommandAddPack = "addPack"
|
||||
CommandAddSticker = "addSticker"
|
||||
|
@ -11,19 +12,26 @@ const (
|
|||
CommandDeletePack = "delPack"
|
||||
CommandReset = "reset"
|
||||
CommandStart = "start"
|
||||
)
|
||||
|
||||
// State... represents current state of user action
|
||||
const (
|
||||
StateNone = "none"
|
||||
StateAddSticker = CommandAddSticker
|
||||
StateAddPack = CommandAddPack
|
||||
StateDeleteSticker = CommandDeleteSticker
|
||||
StateDeletePack = CommandDeletePack
|
||||
StateReset = CommandReset
|
||||
|
||||
SetUploaded = "?"
|
||||
|
||||
LanguageFallback = "en"
|
||||
)
|
||||
|
||||
// SetUploaded is a mimic set name of uploaded stickers without any parent set
|
||||
const SetUploaded = "?"
|
||||
|
||||
// LanguageFallback is a default language code in case what current user language
|
||||
// is not support yet
|
||||
const LanguageFallback = "en"
|
||||
|
||||
// AllowedUpdates is
|
||||
var AllowedUpdates = []string{
|
||||
tg.UpdateInlineQuery, // For searching and sending stickers
|
||||
tg.UpdateMessage, // For get commands and messages
|
||||
|
|
Loading…
Reference in New Issue