Переглянути джерело

Modify UserAgent & Identify properties for user accounts

rigormorrtiss 4 роки тому
батько
коміт
9651934c16
1 змінених файлів з 13 додано та 2 видалено
  1. 13 2
      discordo.go

+ 13 - 2
discordo.go

@@ -71,6 +71,11 @@ func onLoginModalDone(buttonIndex int, buttonLabel string) {
 }
 
 func newSession(email string, password string, token string) *discordgo.Session {
+	userAgent := "" +
+		"Mozilla/5.0 (X11; Linux x86_64) " +
+		"AppleWebKit/537.36 (KHTML, like Gecko) " +
+		"Chrome/91.0.4472.164 Safari/537.36"
+
 	var sess *discordgo.Session
 	var err error
 	if email != "" && password != "" {
@@ -79,6 +84,10 @@ func newSession(email string, password string, token string) *discordgo.Session
 			panic(err)
 		}
 
+		sess.UserAgent = userAgent
+		sess.Identify.Properties.Browser = "Chrome"
+		sess.Identify.Properties.OS = "Linux"
+
 		sess.AddHandler(onReady)
 	} else if token != "" {
 		sess, err = discordgo.New(token)
@@ -87,14 +96,16 @@ func newSession(email string, password string, token string) *discordgo.Session
 		}
 
 		if !strings.HasPrefix(token, "Bot ") {
+			sess.UserAgent = userAgent
+			sess.Identify.Properties.Browser = "Chrome"
+			sess.Identify.Properties.OS = "Linux"
+
 			sess.AddHandler(onReady)
 		}
 	}
 
 	sess.AddHandler(onGuildCreate)
 	sess.AddHandler(onMessageCreate)
-
-	sess.Identify.Intents = discordgo.IntentsAllWithoutPrivileged
 	if err = sess.Open(); err != nil {
 		panic(err)
 	}