Fix message.go
This commit is contained in:
parent
1cdf7e2a28
commit
2bd8370170
19
client.go
19
client.go
|
@ -1,4 +1,4 @@
|
||||||
package mppclient
|
package mppclientgo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
Ws *websocket.Conn
|
Ws *websocket.Conn
|
||||||
|
started bool
|
||||||
|
|
||||||
Uri string
|
Uri string
|
||||||
Token string
|
Token string
|
||||||
|
@ -84,15 +85,29 @@ func (c *Client) IsConnecting() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Start() {
|
func (c *Client) Start() {
|
||||||
// TODO
|
if c.started {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.started = true
|
||||||
|
c.connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Stop() {
|
func (c *Client) Stop() {
|
||||||
|
if !c.started {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.started = false
|
||||||
|
c.Ws.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) connect() {
|
func (c *Client) connect() {
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
if c.Ws == nil {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) bindEventListners() {
|
func (c *Client) bindEventListners() {
|
||||||
|
|
|
@ -13,7 +13,7 @@ type MppTimeMessage struct {
|
||||||
|
|
||||||
type HiMppMessage struct {
|
type HiMppMessage struct {
|
||||||
MppTimeMessage
|
MppTimeMessage
|
||||||
User MppUser `json:"u"`
|
User User `json:"u"`
|
||||||
Motd string `json:"motd"`
|
Motd string `json:"motd"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ type NoteQuotaMppMessage struct {
|
||||||
type ChatMppMessage struct {
|
type ChatMppMessage struct {
|
||||||
MppTimeMessage
|
MppTimeMessage
|
||||||
Message string `json:"a"`
|
Message string `json:"a"`
|
||||||
Part MppParticipant `json:"p"`
|
Part Participant `json:"p"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TimeMppMessage struct {
|
type TimeMppMessage struct {
|
||||||
|
@ -37,6 +37,6 @@ type TimeMppMessage struct {
|
||||||
|
|
||||||
type ChannelMppMessage struct {
|
type ChannelMppMessage struct {
|
||||||
MppMessage
|
MppMessage
|
||||||
Channel MppChannel `json:"ch"`
|
Channel Channel `json:"ch"`
|
||||||
Participants []MppParticipant `json:"ppl"`
|
Participants []Participant `json:"ppl"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package mppclient
|
package mppclientgo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
@ -11,10 +11,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Hri7566/mpp-client-go/events"
|
||||||
"github.com/Hri7566/mpp-client-go/mpp"
|
"github.com/Hri7566/mpp-client-go/mpp"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/joho/godotenv"
|
|
||||||
v8 "rogchap.com/v8go"
|
v8 "rogchap.com/v8go"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -24,6 +24,17 @@ var token string
|
||||||
var ctx *v8.Context
|
var ctx *v8.Context
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
evt := events.NewEventEmitter()
|
||||||
|
|
||||||
|
log := func(args ...any) {
|
||||||
|
fmt.Println(args[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
evt.On("log", log)
|
||||||
|
|
||||||
|
evt.Emit("log", "hello, world")
|
||||||
|
|
||||||
|
/*
|
||||||
ctx = v8.NewContext()
|
ctx = v8.NewContext()
|
||||||
|
|
||||||
helpCommands = commands
|
helpCommands = commands
|
||||||
|
@ -38,6 +49,7 @@ func main() {
|
||||||
token = os.Getenv("MPPNET_TOKEN")
|
token = os.Getenv("MPPNET_TOKEN")
|
||||||
|
|
||||||
StartSocket(addr)
|
StartSocket(addr)
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartSocket(address *string) {
|
func StartSocket(address *string) {
|
||||||
|
|
Loading…
Reference in New Issue