x
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import contextlib
|
import contextlib
|
||||||
import io
|
|
||||||
import json
|
import json
|
||||||
|
import io
|
||||||
|
|
||||||
from asyncio import sleep
|
from asyncio import sleep
|
||||||
|
|
||||||
@@ -18,8 +18,7 @@ pip_install("aiohttp")
|
|||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
uri = "ws://106.52.87.206:8080/bot/pagermaid?secure_token=1a14c723-2150-11ee-af60-5254001a4920"
|
uri = "${rws()}"
|
||||||
|
|
||||||
|
|
||||||
class WebSocket:
|
class WebSocket:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -142,7 +141,7 @@ async def connect_ws():
|
|||||||
await log(f"[ws] Connection failed: {e}")
|
await log(f"[ws] Connection failed: {e}")
|
||||||
|
|
||||||
|
|
||||||
@listener(incoming=True, outgoing=True)
|
@listener(incoming=True, outgoing=False, ignore_edited=True)
|
||||||
async def websocket_push(message: Message):
|
async def websocket_push(message: Message):
|
||||||
with contextlib.suppress(Exception):
|
with contextlib.suppress(Exception):
|
||||||
if message.chat and message.chat.type in [
|
if message.chat and message.chat.type in [
|
||||||
@@ -169,3 +168,4 @@ async def websocket_to_connect(message: Message):
|
|||||||
return await message.edit("傻+ 已连接")
|
return await message.edit("傻+ 已连接")
|
||||||
else:
|
else:
|
||||||
return await message.edit("傻+ 已离线")
|
return await message.edit("傻+ 已离线")
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -573,9 +573,9 @@ func (f *Factory) Sender2(options map[string]string) *CustomSender {
|
|||||||
return sender
|
return sender
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Factory) Sender() interface{} {
|
func (f *Factory) Sender(options map[string]string) interface{} {
|
||||||
return &SenderJsIplm{
|
return &SenderJsIplm{
|
||||||
Message: f.Sender2(nil),
|
Message: f.Sender2(options),
|
||||||
Vm: f.vm,
|
Vm: f.vm,
|
||||||
Private: "private",
|
Private: "private",
|
||||||
Group: "group",
|
Group: "group",
|
||||||
|
|||||||
@@ -384,6 +384,12 @@ func (sender *SenderJsIplm) Listen(ps ...interface{}) interface{} {
|
|||||||
carry.ProhibitGroups = arrayss(p)
|
carry.ProhibitGroups = arrayss(p)
|
||||||
case "prohibt_users":
|
case "prohibt_users":
|
||||||
carry.ProhibitUsers = arrayss(p)
|
carry.ProhibitUsers = arrayss(p)
|
||||||
|
case "user_id":
|
||||||
|
carry.UserID = p.(string)
|
||||||
|
case "chat_id":
|
||||||
|
carry.ChatID = p.(string)
|
||||||
|
case "platform":
|
||||||
|
carry.AllowPlatforms = []string{p.(string)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case bool:
|
case bool:
|
||||||
@@ -431,8 +437,12 @@ func (sender *SenderJsIplm) Listen(ps ...interface{}) interface{} {
|
|||||||
} else if len(carry.AllowPlatforms) == 0 {
|
} else if len(carry.AllowPlatforms) == 0 {
|
||||||
carry.AllowPlatforms = []string{sender.GetPlatform()}
|
carry.AllowPlatforms = []string{sender.GetPlatform()}
|
||||||
}
|
}
|
||||||
|
if carry.UserID != "" {
|
||||||
carry.UserID = sender.GetUserID()
|
carry.UserID = sender.GetUserID()
|
||||||
|
}
|
||||||
|
if carry.ChatID != "" {
|
||||||
carry.ChatID = sender.GetChatID()
|
carry.ChatID = sender.GetChatID()
|
||||||
|
}
|
||||||
carry.UUID = sender.UUID
|
carry.UUID = sender.UUID
|
||||||
options = append(options, carry)
|
options = append(options, carry)
|
||||||
var newJsSender *SenderJsIplm
|
var newJsSender *SenderJsIplm
|
||||||
|
|||||||
+5
-1
@@ -125,9 +125,9 @@ func handleWebsocket(c *gin.Context) {
|
|||||||
time.Sleep(time.Millisecond * 500)
|
time.Sleep(time.Millisecond * 500)
|
||||||
for {
|
for {
|
||||||
_, data, err := ws.ReadMessage()
|
_, data, err := ws.ReadMessage()
|
||||||
|
matched := false
|
||||||
wc.patterns.Range(func(key, value any) bool {
|
wc.patterns.Range(func(key, value any) bool {
|
||||||
wp := value.(*WsPattern)
|
wp := value.(*WsPattern)
|
||||||
matched := false
|
|
||||||
// fmt.Println("wp.Value", wp.Value)
|
// fmt.Println("wp.Value", wp.Value)
|
||||||
for k, v := range wp.Value {
|
for k, v := range wp.Value {
|
||||||
value, _, _, err := jsonparser.Get(data, strings.Split(k, ".")...)
|
value, _, _, err := jsonparser.Get(data, strings.Split(k, ".")...)
|
||||||
@@ -166,9 +166,13 @@ func handleWebsocket(c *gin.Context) {
|
|||||||
} else {
|
} else {
|
||||||
// fmt.Println("err3", err)
|
// fmt.Println("err3", err)
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
if matched {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if err != nil { // disconnect
|
if err != nil { // disconnect
|
||||||
req._event = "disconnect"
|
req._event = "disconnect"
|
||||||
for _, f2 := range Functions {
|
for _, f2 := range Functions {
|
||||||
|
|||||||
Reference in New Issue
Block a user