Archived
1

All code formatted with gofmt

This commit is contained in:
2017-10-18 07:03:34 +04:00
parent df58e25adc
commit 6f374e560e
58 changed files with 1957 additions and 1962 deletions

View File

@@ -4,35 +4,35 @@
package connections
import (
// stdlib
"log"
// 3rd-party
// stdlib
"log"
// 3rd-party
_ "github.com/go-sql-driver/mysql"
"github.com/go-telegram-bot-api/telegram-bot-api"
"github.com/jmoiron/sqlx"
_ "github.com/go-sql-driver/mysql"
// local
"../config"
"github.com/jmoiron/sqlx"
// local
"../config"
)
func BotInit(cfg *config.Config) *tgbotapi.BotAPI {
bot, err := tgbotapi.NewBotAPI(cfg.Telegram.APIToken)
if err != nil {
log.Panic(err)
}
bot, err := tgbotapi.NewBotAPI(cfg.Telegram.APIToken)
if err != nil {
log.Panic(err)
}
bot.Debug = true
bot.Debug = true
log.Printf("Bot version: " + config.VERSION)
log.Printf("Authorized on account %s", bot.Self.UserName)
log.Printf("Bot version: " + config.VERSION)
log.Printf("Authorized on account %s", bot.Self.UserName)
return bot
return bot
}
func DBInit(cfg *config.Config) *sqlx.DB {
database, err := sqlx.Connect("mysql", cfg.Database.User + ":" + cfg.Database.Password + "@tcp(" + cfg.Database.Host + ":" + cfg.Database.Port + ")/" + cfg.Database.Database + "?parseTime=true&charset=utf8mb4,utf8")
if err != nil {
log.Fatal(err)
}
log.Printf("Database connection established!")
return database
database, err := sqlx.Connect("mysql", cfg.Database.User+":"+cfg.Database.Password+"@tcp("+cfg.Database.Host+":"+cfg.Database.Port+")/"+cfg.Database.Database+"?parseTime=true&charset=utf8mb4,utf8")
if err != nil {
log.Fatal(err)
}
log.Printf("Database connection established!")
return database
}