mirror of
https://git.phreedom.club/localhost_frssoft/mastodon-group-bot.git
synced 2024-12-26 11:09:47 +00:00
bug fix
This commit is contained in:
parent
8c6e023e51
commit
660e3758ca
28
bot.go
28
bot.go
@ -42,22 +42,11 @@ func RunBot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
notif := notifEvent.Notification
|
notif := notifEvent.Notification
|
||||||
ntype := notif.Type
|
|
||||||
acct := notif.Status.Account.Acct
|
|
||||||
content := notif.Status.Content
|
|
||||||
tooturl := notif.Status.URL
|
|
||||||
|
|
||||||
/*postToot := func(toot string, vis string) (*mastodon.Status, error) {
|
|
||||||
conToot := mastodon.Toot{
|
|
||||||
Status: toot,
|
|
||||||
Visibility: vis,
|
|
||||||
}
|
|
||||||
status, err := c.PostStatus(ctx, &conToot)
|
|
||||||
return status, err
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// New follower
|
// New follower
|
||||||
if ntype == "follow" {
|
if notif.Type == "follow" {
|
||||||
|
acct := notif.Status.Account.Acct
|
||||||
|
|
||||||
if !exist_in_database(acct) { // Add to db and post welcome message
|
if !exist_in_database(acct) { // Add to db and post welcome message
|
||||||
InfoLogger.Printf("%s followed", acct)
|
InfoLogger.Printf("%s followed", acct)
|
||||||
|
|
||||||
@ -74,8 +63,12 @@ func RunBot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read message
|
// Read message
|
||||||
if ntype == "mention" {
|
if notif.Type == "mention" {
|
||||||
for i := 0; i < len(followers); i++ {
|
acct := notif.Status.Account.Acct
|
||||||
|
content := notif.Status.Content
|
||||||
|
tooturl := notif.Status.URL
|
||||||
|
|
||||||
|
for i := range followers {
|
||||||
if acct == string(followers[i].Acct) { // Follow check
|
if acct == string(followers[i].Acct) { // Follow check
|
||||||
if notif.Status.Visibility == "public" { // Reblog toot
|
if notif.Status.Visibility == "public" { // Reblog toot
|
||||||
if notif.Status.InReplyToID == nil { // Not boost replies
|
if notif.Status.InReplyToID == nil { // Not boost replies
|
||||||
@ -124,9 +117,10 @@ func RunBot() {
|
|||||||
recmd := regexp.MustCompile(`<[^>]+>`)
|
recmd := regexp.MustCompile(`<[^>]+>`)
|
||||||
command := recmd.ReplaceAllString(content, "")
|
command := recmd.ReplaceAllString(content, "")
|
||||||
args := strings.Split(command, " ")
|
args := strings.Split(command, " ")
|
||||||
mID := mastodon.ID((args[2]))
|
|
||||||
|
|
||||||
if len(args) == 3 {
|
if len(args) == 3 {
|
||||||
|
mID := mastodon.ID((args[2]))
|
||||||
|
|
||||||
switch args[1] {
|
switch args[1] {
|
||||||
case "unboost":
|
case "unboost":
|
||||||
c.Unreblog(ctx, mID)
|
c.Unreblog(ctx, mID)
|
||||||
|
18
cleaning.go
18
cleaning.go
@ -21,16 +21,18 @@ func DeleteNotices() {
|
|||||||
ErrorLogger.Println("Get account statuses")
|
ErrorLogger.Println("Get account statuses")
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(time.Duration(Conf.Del_notices_interval) * time.Second)
|
time.Sleep(time.Duration(Conf.Del_notices_interval) * time.Minute)
|
||||||
|
|
||||||
for i := range statuses {
|
if len(statuses) > 0 {
|
||||||
if statuses[i].Visibility == "direct" {
|
for i := range statuses {
|
||||||
c.DeleteStatus(ctx, statuses[i].ID)
|
if statuses[i].Visibility == "direct" {
|
||||||
|
c.DeleteStatus(ctx, statuses[i].ID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
InfoLogger.Println("Cleaning notices")
|
||||||
InfoLogger.Println("Cleaning notices")
|
|
||||||
|
|
||||||
reset_notice_counter()
|
reset_notice_counter()
|
||||||
InfoLogger.Println("Reset notice counter")
|
InfoLogger.Println("Reset notice counter")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user