Disable/Enable boosts admin command

This commit is contained in:
localhost_frssoft 2023-05-28 16:26:59 +03:00
parent bf14452ab7
commit 6e6283dfb0

23
bot.go
View File

@ -25,6 +25,7 @@ var (
ctx = context.Background() ctx = context.Background()
my_account, _ = c.GetAccountCurrentUser(ctx) my_account, _ = c.GetAccountCurrentUser(ctx)
boostsenabled = true
) )
type APobject struct { type APobject struct {
@ -70,7 +71,7 @@ func CheckAPReply(tooturl string) (bool) {
return false return false
} }
if apobj.InReplyTo != nil { if apobj.InReplyTo != nil {
WarnLogger.Printf("AP object of status detected reply: %s", apobj.InReplyTo) WarnLogger.Printf("AP object of status detected reply: %s", &apobj.InReplyTo)
return true return true
} }
return false return false
@ -126,6 +127,9 @@ func RunBot() {
// Follow check // Follow check
if relationship[0].FollowedBy { if relationship[0].FollowedBy {
if notif.Status.Visibility == "public" { // Reblog toot if notif.Status.Visibility == "public" { // Reblog toot
if boostsenabled == false {
continue
}
var APreply bool var APreply bool
APreply = false APreply = false
if notif.Status.InReplyToID == nil { if notif.Status.InReplyToID == nil {
@ -192,9 +196,26 @@ func RunBot() {
case "delete": case "delete":
c.DeleteStatus(ctx, mID) c.DeleteStatus(ctx, mID)
WarnLogger.Printf("%s was deleted", mID) WarnLogger.Printf("%s was deleted", mID)
case "disable":
boostsenabled = false
WarnLogger.Printf("Reblogs disabled by admin")
case "enable":
boostsenabled = true
WarnLogger.Printf("Reblogs enabled by admin")
default: default:
WarnLogger.Printf("%s entered wrong command", acct) WarnLogger.Printf("%s entered wrong command", acct)
} }
} else if len(args) == 2 {
switch args[1] {
case "disable":
boostsenabled = false
WarnLogger.Printf("Reblogs disabled by admin")
case "enable":
boostsenabled = true
WarnLogger.Printf("Reblogs enabled by admin")
default:
WarnLogger.Printf("%s entered wrong command", acct)
}
} else { } else {
WarnLogger.Printf("%s entered wrong command", acct) WarnLogger.Printf("%s entered wrong command", acct)
} }