Skip to content

Commit

Permalink
添加管理员权限验证
Browse files Browse the repository at this point in the history
  • Loading branch information
IJNKAWAKAZE committed Jun 28, 2024
1 parent f41d73b commit 2b00c7a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/fsnotify/fsnotify v1.6.0
github.com/gin-gonic/gin v1.9.1
github.com/go-redis/redis/v8 v8.11.5
github.com/ijnkawakaze/telegram-bot-api v1.0.7
github.com/ijnkawakaze/telegram-bot-api v1.0.8
github.com/matoous/go-nanoid/v2 v2.0.0
github.com/playwright-community/playwright-go v0.2000.1
github.com/robfig/cron/v3 v3.0.0
Expand Down
4 changes: 2 additions & 2 deletions src/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ijnkawakaze/telegram-bot-api v1.0.7 h1:QjPDEccFJUa1VjQmsmkwwFSmkJDSjVRz95cSif+/7mU=
github.com/ijnkawakaze/telegram-bot-api v1.0.7/go.mod h1:jXTw4A2ySR+sof3J4R/ODl99MwFqeoXbWyyhWACGh+E=
github.com/ijnkawakaze/telegram-bot-api v1.0.8 h1:8XnoMd0Hnf5JpsqFjxkwZXDVv+/gqmhcyvFh4buwtgM=
github.com/ijnkawakaze/telegram-bot-api v1.0.8/go.mod h1:jXTw4A2ySR+sof3J4R/ODl99MwFqeoXbWyyhWACGh+E=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/gatekeeper/callback_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func CallBackData(callBack tgbotapi.Update) error {

if d[2] == "PASS" || d[2] == "BAN" {

if !bot.Arknights.IsAdmin(chatId, callbackQuery.From.ID) {
if !bot.Arknights.IsAdminWithPermissions(chatId, callbackQuery.From.ID, 16) {
callbackQuery.Answer(true, "无使用权限!")
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/system/callback_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func Report(callBack tgbotapi.Update) error {
target, _ := strconv.ParseInt(d[2], 10, 64)
targetMessageId, _ := strconv.Atoi(d[3])

if !bot.Arknights.IsAdmin(chatId, userId) {
if !bot.Arknights.IsAdminWithPermissions(chatId, userId, 16) {
callbackQuery.Answer(true, "无使用权限!")
return nil
}
Expand Down
30 changes: 14 additions & 16 deletions src/utils/base_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (

var ctx = context.Background()

var browser playwright.Browser

type GroupInvite struct {
Id string `json:"id" gorm:"primaryKey"`
GroupName string `json:"groupName"`
Expand Down Expand Up @@ -247,27 +249,23 @@ func RedisDelSetItem(key string, val string) {

// Screenshot 屏幕截图
func Screenshot(url string, waitTime float64, scale float64) []byte {
pw, err := playwright.Run()
if err != nil {
log.Println("未检测到playwright,开始自动安装...")
playwright.Install()
pw, _ = playwright.Run()
}
browser, err := pw.Chromium.Launch()
if err != nil {
log.Println(err)
return nil
if browser == nil {
pw, err := playwright.Run()
if err != nil {
log.Println("未检测到playwright,开始自动安装...")
playwright.Install()
pw, _ = playwright.Run()
}
browser, err = pw.Chromium.Launch()
if err != nil {
log.Println(err)
return nil
}
}
page, _ := browser.NewPage(playwright.BrowserNewContextOptions{DeviceScaleFactor: &scale})
if err != nil {
log.Println(err)
return nil
}
defer func() {
log.Println("关闭playwright")
page.Close()
browser.Close()
pw.Stop()
}()
log.Println("开始进行截图...")
page.Goto(url, playwright.PageGotoOptions{
Expand Down

0 comments on commit 2b00c7a

Please sign in to comment.