|
@@ -1,20 +1,39 @@
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
+ "fmt"
|
|
|
"log"
|
|
|
+ "os"
|
|
|
+ "time"
|
|
|
+
|
|
|
+ "github.com/JamZYM/golagrange/api"
|
|
|
+ "github.com/joho/godotenv"
|
|
|
)
|
|
|
|
|
|
func main() {
|
|
|
- conn := golagrange.api.websocketBot("localhost", 5101, "")
|
|
|
- defer conn.Close()
|
|
|
-
|
|
|
- for {
|
|
|
- id, message, err := conn.ReadMessage()
|
|
|
- if err != nil {
|
|
|
- log.Println("read:", err)
|
|
|
- return
|
|
|
- }
|
|
|
- log.Printf("recv: %s", id)
|
|
|
- log.Printf("recv: %s", message)
|
|
|
+ err := godotenv.Load()
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal("Error loading .env file")
|
|
|
}
|
|
|
+
|
|
|
+ connBot := api.WebsocketBot(os.Getenv("HOST"), os.Getenv("PORT"), os.Getenv("PATH"))
|
|
|
+ defer connBot.Wsconn.Close()
|
|
|
+
|
|
|
+ go func() {
|
|
|
+ for {
|
|
|
+ _, message, err := connBot.Wsconn.ReadMessage()
|
|
|
+ if err != nil {
|
|
|
+ log.Println("read:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ log.Printf("recv: %s", message)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ connBot.Send_private_msg(2945340446, "Hello, world!")
|
|
|
+ err = connBot.Upload_private_file(2945340446, "/home/jam/Documents/College/大学学习/大创/基于gm_Id方法的跨阻放大器设计_林佳辉.pdf", "基于gm_Id方法的跨阻放大器设计_林佳辉.pdf")
|
|
|
+ fmt.Println(err)
|
|
|
+
|
|
|
+ time.Sleep(10 * time.Second)
|
|
|
+
|
|
|
}
|