go fmt
This commit is contained in:
parent
4c0d2ec3a3
commit
38c7bef71c
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"log"
|
||||||
|
|
||||||
"gorm.io/driver/sqlite"
|
"gorm.io/driver/sqlite"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
@ -71,5 +71,5 @@ func (bc BotController) GetUser(UserID int64) User {
|
|||||||
bc.db.Create(&user)
|
bc.db.Create(&user)
|
||||||
}
|
}
|
||||||
|
|
||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,11 +17,9 @@ var adminCommands = map[string]func(BotController, tgbotapi.Update){
|
|||||||
"/panel": handleMessage, // open bot settings
|
"/panel": handleMessage, // open bot settings
|
||||||
"/usermode": handleMessage, // temporarly disable admin mode to test ui
|
"/usermode": handleMessage, // temporarly disable admin mode to test ui
|
||||||
"/id": handleMessage, // to check id of chat
|
"/id": handleMessage, // to check id of chat
|
||||||
"/setchannelid": handleMessage, // just type it in channel which one is
|
"/setchannelid": handleMessage, // just type it in channel which one is supposed to be lined with bot
|
||||||
// supposed to be lined with bot
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var bc = GetBotController()
|
var bc = GetBotController()
|
||||||
|
|
||||||
@ -42,7 +40,7 @@ func ProcessUpdate(bc BotController, update tgbotapi.Update) {
|
|||||||
|
|
||||||
func handleMessage(bc BotController, update tgbotapi.Update) {
|
func handleMessage(bc BotController, update tgbotapi.Update) {
|
||||||
var UserID = update.Message.From.ID
|
var UserID = update.Message.From.ID
|
||||||
user := bc.GetUser(UserID)
|
user := bc.GetUser(UserID)
|
||||||
|
|
||||||
bc.db.Model(&user).Update("MsgCounter", user.MsgCounter+1)
|
bc.db.Model(&user).Update("MsgCounter", user.MsgCounter+1)
|
||||||
log.Printf("User[%d] messages: %d", user.ID, user.MsgCounter)
|
log.Printf("User[%d] messages: %d", user.ID, user.MsgCounter)
|
||||||
@ -70,7 +68,7 @@ func handleMessage(bc BotController, update tgbotapi.Update) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleCallbackQuery(bc BotController, update tgbotapi.Update) {
|
func handleCallbackQuery(bc BotController, update tgbotapi.Update) {
|
||||||
user := bc.GetUser(update.CallbackQuery.From.ID)
|
user := bc.GetUser(update.CallbackQuery.From.ID)
|
||||||
|
|
||||||
if update.CallbackQuery.Data == "leave_ticket_button" {
|
if update.CallbackQuery.Data == "leave_ticket_button" {
|
||||||
handleLeaveTicketButton(bc, update, user)
|
handleLeaveTicketButton(bc, update, user)
|
||||||
@ -347,12 +345,11 @@ func DownloadFile(filepath string, url string) error {
|
|||||||
|
|
||||||
func notifyAdminAboutError(bc BotController, errorMessage string) {
|
func notifyAdminAboutError(bc BotController, errorMessage string) {
|
||||||
// Check if AdminID is set in the config
|
// Check if AdminID is set in the config
|
||||||
adminID := *bc.cfg.AdminID
|
adminID := *bc.cfg.AdminID
|
||||||
if adminID == 0 {
|
if adminID == 0 {
|
||||||
log.Println("AdminID is not set in the configuration.")
|
log.Println("AdminID is not set in the configuration.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
msg := tgbotapi.NewMessage(
|
msg := tgbotapi.NewMessage(
|
||||||
adminID,
|
adminID,
|
||||||
fmt.Sprintf("Error occurred: %s", errorMessage),
|
fmt.Sprintf("Error occurred: %s", errorMessage),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user