Skip to content

Commit

Permalink
style: Format code with gofumpt and gofmt
Browse files Browse the repository at this point in the history
Format code with gofumpt and gofmt

This commit fixes the style issues introduced in 9b91659 according to the output
from gofumpt and gofmt.

Details: https://app.deepsource.com/gh/soekarnohatta/SiskamlingBot/transform/c8467f22-014b-460b-b429-ff4852a8103a/
  • Loading branch information
deepsource-autofix[bot] committed Apr 17, 2023
1 parent 9b91659 commit 819275e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
5 changes: 2 additions & 3 deletions bot/core/app/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package app

import (
"SiskamlingBot/bot/core/telegram/types"
"SiskamlingBot/bot/utils"
"fmt"
"html"
"log"
Expand All @@ -11,9 +13,6 @@ import (
"github.com/PaulSonOfLars/gotgbot/v2"
"github.com/PaulSonOfLars/gotgbot/v2/ext"
"github.com/shirou/gopsutil/host"

"SiskamlingBot/bot/core/telegram/types"
"SiskamlingBot/bot/utils"
)

type MyApp struct {
Expand Down
39 changes: 20 additions & 19 deletions bot/modules/picture/picture.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"SiskamlingBot/bot/core/telegram"
"SiskamlingBot/bot/utils"
"fmt"
"github.com/PaulSonOfLars/gotgbot/v2/ext"
"regexp"
"sync"

"github.com/PaulSonOfLars/gotgbot/v2/ext"
)

func (m *Module) pictureScan(ctx *telegram.TgContext) error {
var getPref, _ = m.App.DB.Pref.GetPreferenceById(ctx.Chat.Id)
getPref, _ := m.App.DB.Pref.GetPreferenceById(ctx.Chat.Id)
if getPref != nil && !getPref.EnforcePicture {
return telegram.ContinueOrder
}
Expand All @@ -19,34 +20,34 @@ func (m *Module) pictureScan(ctx *telegram.TgContext) error {
defer wg.Wait()
wg.Add(1)

var rstrChan = make(chan bool, 1)
var untilDate = utils.ExtractTime("5m")
var toDeleteServiceMessage = getPref.LastServiceMessageId
var toDeleteAndSave = ctx.Message.MessageId
rstrChan := make(chan bool, 1)
untilDate := utils.ExtractTime("5m")
toDeleteServiceMessage := getPref.LastServiceMessageId
toDeleteAndSave := ctx.Message.MessageId

go func() { rstrChan <- ctx.RestrictMember(0, 0, untilDate) }()
go func() { ctx.DeleteMessage(toDeleteServiceMessage); wg.Done() }()

var dataButton = map[string]string{
dataButton := map[string]string{
"1": utils.Int64ToStr(ctx.User.Id),
"2": utils.Int64ToStr(ctx.Chat.Id),
}

var dataGroup = map[string]string{
dataGroup := map[string]string{
"1": telegram.MentionHtml(ctx.User.Id, ctx.User.FirstName),
"2": utils.Int64ToStr(ctx.User.Id),
"3": utils.IntToStr(0),
}

var dataPrivate = map[string]string{
dataPrivate := map[string]string{
"1": telegram.MentionHtml(ctx.User.Id, ctx.User.FirstName),
"2": utils.Int64ToStr(ctx.User.Id),
"3": ctx.Chat.Title,
}

var txtGroup, keybGroup = telegram.CreateMenuKeyboardf("./data/menu/picture_group.json", 1, dataGroup, dataButton)
var txtPrivate, keybPrivate = telegram.CreateMenuKeyboardf("./data/menu/picture_private.json", 1, dataPrivate, dataButton)
var txtLog = fmt.Sprintf(
txtGroup, keybGroup := telegram.CreateMenuKeyboardf("./data/menu/picture_group.json", 1, dataGroup, dataButton)
txtPrivate, keybPrivate := telegram.CreateMenuKeyboardf("./data/menu/picture_private.json", 1, dataPrivate, dataButton)
txtLog := fmt.Sprintf(
"#PICTURE"+
"\n<b>User Name:</b> %s"+
"\n<b>User ID:</b> <code>%v</code>"+
Expand All @@ -65,7 +66,7 @@ func (m *Module) pictureScan(ctx *telegram.TgContext) error {
ctx.SendMessage(txtGroup, 0)
getPref.LastServiceMessageId = ctx.Message.MessageId

var err = m.App.DB.Pref.SavePreference(getPref)
err := m.App.DB.Pref.SavePreference(getPref)
if err != nil {
return err
}
Expand All @@ -76,7 +77,7 @@ func (m *Module) pictureScan(ctx *telegram.TgContext) error {
go func() {
ctx.SendMessageKeyboard(txtGroup, 0, keybGroup)
getPref.LastServiceMessageId = ctx.Message.MessageId
var _ = m.App.DB.Pref.SavePreference(getPref)
_ = m.App.DB.Pref.SavePreference(getPref)
wg.Done()
}()

Expand All @@ -91,8 +92,8 @@ func (m *Module) pictureCallbackGroup(ctx *telegram.TgContext) error {
return ext.ContinueGroups
}

var pattern, _ = regexp.Compile(`picture\((.+?)\)\((.+?)\)`)
var userId = utils.StrToInt64(pattern.FindStringSubmatch(ctx.Callback.Data)[1])
pattern, _ := regexp.Compile(`picture\((.+?)\)\((.+?)\)`)
userId := utils.StrToInt64(pattern.FindStringSubmatch(ctx.Callback.Data)[1])

if !(userId == ctx.Callback.From.Id) {
if p, err := ctx.Callback.From.GetProfilePhotos(ctx.Bot, nil); p != nil && p.TotalCount == 0 {
Expand Down Expand Up @@ -139,9 +140,9 @@ func (m *Module) pictureCallbackPrivate(ctx *telegram.TgContext) error {
return ext.ContinueGroups
}

var pattern, _ = regexp.Compile(`picture\((.+?)\)\((.+?)\)`)
var userId = utils.StrToInt64(pattern.FindStringSubmatch(ctx.Callback.Data)[1])
var chatId = utils.StrToInt64(pattern.FindStringSubmatch(ctx.Callback.Data)[2])
pattern, _ := regexp.Compile(`picture\((.+?)\)\((.+?)\)`)
userId := utils.StrToInt64(pattern.FindStringSubmatch(ctx.Callback.Data)[1])
chatId := utils.StrToInt64(pattern.FindStringSubmatch(ctx.Callback.Data)[2])

if !(userId == ctx.Callback.From.Id) {
ctx.AnswerCallback("Anda dilarang menggunakan tombol ini!", true)
Expand Down

0 comments on commit 819275e

Please sign in to comment.