Skip to content

Commit

Permalink
同步
Browse files Browse the repository at this point in the history
  • Loading branch information
kyokukong committed Sep 20, 2024
1 parent a012a64 commit 57d59f0
Show file tree
Hide file tree
Showing 9 changed files with 679 additions and 64 deletions.
10 changes: 4 additions & 6 deletions adapter/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Bot interface {

GetLoginInfo() *resource.Login // 获取登录信息

SendContent(channelId string, content string) (*resource.Message, error) // 发送纯文本消息
SendContent(groupId string, channelId string, content string) (*resource.Message, error) // 发送纯文本消息
GetMessage(channelId string, messageId string) (*resource.Message, error) // (从缓存中)获取指定消息
RecallMessage(channelId string, messageId string) error // 撤回指定消息
UpdateMessage(channelId string, messageId string, content string) error // 编辑指定消息
Expand All @@ -63,11 +63,9 @@ type Bot interface {
// Iceinu的特有API
// 其中一部分是对各个平台功能的扩展适配,还有一部分是其他功能的快捷方式

Send(elements []elements.IceinuMessageElement) (*resource.Message, error) // 直接发送Iceinu通用元素
SendSatori(satori string) (*resource.Message, error) // 发送Satori XHTML格式的消息字符串,自动解析成通用元素并发送
SendPoke(userId string) error // 发送戳一戳
SendGroupPoke(groupId string) error // 发送群组戳一戳
SendChannelPoke(channelId string) error // 发送频道戳一戳
Send(groupId string, channelId string, elements []elements.IceinuMessageElement) (*resource.Message, error) // 直接发送Iceinu通用元素
SendSatori(groupId string, channelId string, satori string) (*resource.Message, error) // 发送Satori XHTML格式的消息字符串,自动解析成通用元素并发送
SendPoke(groupId string, channelId string, userId string) error // 发送戳一戳

GetSelfUserId() string // 获取自己的用户ID
GetSelfUserName() string // 获取自己的用户名
Expand Down
14 changes: 5 additions & 9 deletions adapter/lagrange/element_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func ConvertIceElement(e []message.IMessageElement) *[]elements.IceinuMessageEle
Id: strconv.Itoa(int(ele.TargetUin)),
Name: ele.Display,
Role: "",
Type: "",
Type: strconv.Itoa(int(ele.Type())),
})
case message.Face:
ele := ele.(*message.FaceElement)
Expand All @@ -54,18 +54,14 @@ func ConvertIceElement(e []message.IMessageElement) *[]elements.IceinuMessageEle
Title: ele.Name,
Duration: ele.Size,
Poster: "",
Cache: false,
Timeout: "",
})
case message.Image:
ele := ele.(*message.ImageElement)
IceinuElements = append(IceinuElements, &elements.ImageElement{
Src: ele.Url,
Width: ele.Width,
Height: ele.Height,
Title: ele.ImageId,
Cache: false,
Timeout: "",
Src: ele.Url,
Width: ele.Width,
Height: ele.Height,
Title: ele.ImageId,
})
case message.File:
ele := ele.(*message.FileElement)
Expand Down
17 changes: 17 additions & 0 deletions adapter/lagrange/lagrange_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/Iceinu-Project/iceinu/config"
"github.com/Iceinu-Project/iceinu/ice"
"github.com/Iceinu-Project/iceinu/logger"
"github.com/Iceinu-Project/iceinu/utils"
"github.com/LagrangeDev/LagrangeGo/client"
"github.com/LagrangeDev/LagrangeGo/client/auth"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -80,6 +81,22 @@ func (lgr *AdapterLagrange) Init() {
return
}

var bot = GetBot()

// 刷新client的缓存
err = LgrClient.RefreshAllGroupsInfo()
if err != nil {
return
}
err = LgrClient.RefreshFriendCache()
if err != nil {
return
}
err = LgrClient.RefreshFriendCache()

utils.JPrint(bot.GetGroupMemberList("970801565"))
bot.SendContent("0", "2913844577", "测试消息")

// 设置事件订阅器,将LagrangeGo的事件转换并发送到iceinu的事件总线上
SetAllHandler()
SetAllSubscribes()
Expand Down
Loading

0 comments on commit 57d59f0

Please sign in to comment.