🚨 Removed linter warnings

This commit is contained in:
Maxim Lebedev 2018-03-26 18:10:36 +05:00
parent 2df726ad32
commit 07aaebdc65
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F
7 changed files with 41 additions and 12 deletions

View File

@ -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()
}

View File

@ -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

View File

@ -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
)

View File

@ -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

View File

@ -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 {

View File

@ -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)
}
}

View File

@ -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