🔀 Merge branch 'develop'

This commit is contained in:
Maxim Lebedev 2018-03-26 18:12:36 +05:00
commit ebfabb48be
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F
24 changed files with 56 additions and 26 deletions

View File

@ -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. 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:** **These people sponsored current version of the project:**
- Yami Odymel
- Daniil Tlenov
- Aurielb - Aurielb
- MoD21k - Daniil Tlenov
- @kirillDanshin
- MoD21k
- @YamiOdymel

View File

@ -12,11 +12,11 @@ button_share:
button_add_sticker: button_add_sticker:
other: Add sticker other: Add sticker
button_add_pack: button_add_pack:
other: 📦 Add pack other: 📦 Add set
button_del_sticker: button_del_sticker:
other: 🗑 Delete sticker other: 🗑 Delete sticker
button_del_pack: button_del_pack:
other: 🗑 Delete pack other: 🗑 Delete set
button_reset: button_reset:
other: 🔥 Reset pack other: 🔥 Reset pack
button_cancel: button_cancel:

View File

@ -1,11 +1,11 @@
cancel_add_sticker: cancel_add_sticker:
other: You cancelled the process of adding a new stickers to your pack. other: You cancelled the process of adding a new stickers to your pack.
cancel_add_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: cancel_del_sticker:
other: You cancelled the process of removing a stickers from your pack. other: You cancelled the process of removing a stickers from your pack.
cancel_del_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: cancel_reset:
other: You cancelled the process of reseting your stickers pack. other: You cancelled the process of reseting your stickers pack.
cancel_error: cancel_error:

View File

@ -1,17 +1,17 @@
error_already_add_sticker: error_already_add_sticker:
other: This sticker is already in your pack. other: This sticker is already in your pack.
error_already_add_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: error_already_del_sticker:
other: Maybe this sticker is already removed from your pack. other: Maybe this sticker is already removed from your pack.
error_already_del_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: error_already_reset:
other: There is nothing to reset, pack is already empty. other: There is nothing to reset, pack is already empty.
error_reset_phrase: error_reset_phrase:
other: Invalid phrase of resetting. This action has been canceled. other: Invalid phrase of resetting. This action has been canceled.
error_empty_del: 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: error_empty_add_pack:
other: You try to add a sticker that exists outside the packs. Use /{{.AddStickerCommand}} instead. other: You try to add a sticker that exists outside the packs. Use /{{.AddStickerCommand}} instead.
error_unknown: error_unknown:

View File

@ -1,12 +1,12 @@
reply_start: reply_start:
other: | other: |
Hello, I'm the [@{{.Username}}](tg://user?id={{.ID}})! 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. Without limits and installing. In any chat. For free.
reply_add_sticker: 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: 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: reply_del_sticker:
other: Send an existing stickers from your pack for removing it. other: Send an existing stickers from your pack for removing it.
reply_del_pack: reply_del_pack:
@ -20,7 +20,7 @@ reply_reset:
reply_help: reply_help:
other: | other: |
/{{.AddStickerCommand}} - add a single sticker to your pack /{{.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 /{{.DeleteStickerCommand}} - remove a single sticker from your pack
/{{.DeletePackCommand}} - remove a sticker set from your pack /{{.DeletePackCommand}} - remove a sticker set from your pack
/{{.ResetCommand}} - remove all stickers from your pack /{{.ResetCommand}} - remove all stickers from your pack

View File

@ -5,14 +5,24 @@ import (
"github.com/toby3d/MyPackBot/internal/bot" "github.com/toby3d/MyPackBot/internal/bot"
"github.com/toby3d/MyPackBot/internal/config" "github.com/toby3d/MyPackBot/internal/config"
"github.com/toby3d/MyPackBot/internal/db" "github.com/toby3d/MyPackBot/internal/db"
"github.com/toby3d/MyPackBot/internal/errors"
"github.com/toby3d/MyPackBot/internal/i18n" "github.com/toby3d/MyPackBot/internal/i18n"
) )
// init prepare configuration and other things for successful start // init prepare configuration and other things for successful start
func init() { func init() {
log.Ln("Initializing...") log.Ln("Initializing...")
i18n.Open("translations/") // Preload localization strings
config.Open("configs/config.yaml") // Preload configuration file // Preload localization strings
db.Open("stickers.db") // Open database or create new one err := i18n.Open("i18n/")
bot.New() // Create bot with credentials from config 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()
} }

View File

@ -6,6 +6,7 @@ import (
tg "github.com/toby3d/telegram" tg "github.com/toby3d/telegram"
) )
// Bot is a main object of Telegram bot
var Bot *tg.Bot var Bot *tg.Bot
// New just create new bot by configuration credentials // New just create new bot by configuration credentials

View File

@ -6,7 +6,10 @@ import (
) )
var ( var (
Config *config.Config // Config is a main object of preloaded configuration YAML
Config *config.Config
// ChannelID is a announcements channel ID
ChannelID int64 ChannelID int64
) )

View File

@ -6,6 +6,7 @@ import (
"github.com/toby3d/MyPackBot/internal/errors" "github.com/toby3d/MyPackBot/internal/errors"
) )
// DB is a main object of current database connection
var DB *buntdb.DB var DB *buntdb.DB
// Open just open connection to database for work // Open just open connection to database for work

View File

@ -8,7 +8,7 @@ import (
"github.com/tidwall/buntdb" "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) { func Users() ([]int, error) {
var users []int var users []int
err := DB.View(func(tx *buntdb.Tx) error { err := DB.View(func(tx *buntdb.Tx) error {

View File

@ -8,8 +8,10 @@ import (
) )
var ( var (
// WaitForwards is a wait group which wait send all announcements before panic
WaitForwards = new(sync.WaitGroup) WaitForwards = new(sync.WaitGroup)
sysLogger *syslog.Writer
sysLogger *syslog.Writer
) )
// Check helps debug critical errors without warnings from 'gocyclo' linter // 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 // Wait what all users get announcement message first
WaitForwards.Wait() WaitForwards.Wait()
sysLogger.Crit(err.Error()) err = sysLogger.Crit(err.Error())
if err != nil {
log.Panicln(err.Error())
}
os.Exit(1) os.Exit(1)
} }
} }

View File

@ -2,6 +2,7 @@ package models
import tg "github.com/toby3d/telegram" import tg "github.com/toby3d/telegram"
// Commands... represents available and supported bot commands
const ( const (
CommandAddPack = "addPack" CommandAddPack = "addPack"
CommandAddSticker = "addSticker" CommandAddSticker = "addSticker"
@ -11,19 +12,26 @@ const (
CommandDeletePack = "delPack" CommandDeletePack = "delPack"
CommandReset = "reset" CommandReset = "reset"
CommandStart = "start" CommandStart = "start"
)
// State... represents current state of user action
const (
StateNone = "none" StateNone = "none"
StateAddSticker = CommandAddSticker StateAddSticker = CommandAddSticker
StateAddPack = CommandAddPack StateAddPack = CommandAddPack
StateDeleteSticker = CommandDeleteSticker StateDeleteSticker = CommandDeleteSticker
StateDeletePack = CommandDeletePack StateDeletePack = CommandDeletePack
StateReset = CommandReset 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{ var AllowedUpdates = []string{
tg.UpdateInlineQuery, // For searching and sending stickers tg.UpdateInlineQuery, // For searching and sending stickers
tg.UpdateMessage, // For get commands and messages tg.UpdateMessage, // For get commands and messages