this post was submitted on 06 Jul 2023
10 points (100.0% liked)

Home

453 readers
1 users here now

Lemmy.zip instance discussion.

For all things relating to Lemmy.zip.

Main instance rules apply, with the additional rules below:

founded 1 year ago
MODERATORS
10
submitted 1 year ago* (last edited 1 year ago) by Demigodrick to c/home
 

Hello all - small request if you have a couple of minutes. Please could you send ZippyBot a message with just #score

Im testing the bots capacity to do multiple things at once, so the more it gets spammed the better! I'll leave this message up for 10/15 minutes or until the bot breaks.

If you get no reply, RIP ZippyBot

Edit: going to leave it running for a while, see how it gets on.

I suppose your score would be closest to reddit "karma"

you are viewing a single comment's thread
view the rest of the comments
[–] Thoxy 2 points 1 year ago* (last edited 1 year ago)

Your welcome ^^

package main

import (
	"bytes"
	"net/http"
	"sync"
)

func main() {
	client := http.Client{}
	wg := &sync.WaitGroup{}
	for i := 0; i < 100; i++ {
		wg.Add(1)
		go func() {
			bodyReader := bytes.NewReader(
				[]byte(
					`{"content":"#score","recipient_id":303747,"auth":"..............."}`,
				),
			)
			req, err := http.NewRequest(
				"POST",
				"https://lemmy.zip/api/v3/private_message",
				bodyReader,
			)
			if err != nil {
				panic(err)
			}
			req.Header.Set("Accept", "*/*")
			req.Header.Set(
				"User-Agent",
				"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0",
			)
			req.Header.Set("Accept-Language", "fr-FR,fr;q=0.8,en-US;q=0.5,en;q=0.3")
			req.Header.Set("Accept-Encoding", "gzip, deflate, br")
			req.Header.Set("Content-Type", "application/json")
			req.Header.Set("Referer", "https://lemmy.zip/create_private_message/303747")
			req.Header.Set("Origin", "https://lemmy.zip")
			req.Header.Set("DNT", "1")
			req.Header.Set("Sec-Fetch-Dest", "empty")
			req.Header.Set("Connection", "keep-alive")
			client.Do(req)
			wg.Done()
		}()
	}
	wg.Wait()
}