init: Initial commit

This commit is contained in:
Björn Benouarets
2026-01-20 06:53:05 +01:00
commit fc8238759a
31 changed files with 1384 additions and 0 deletions

53
app/bot/message.go Normal file
View File

@@ -0,0 +1,53 @@
package bot
import "encoding/json"
type Message struct {
IsGroup bool `json:"isGroup"`
ChannelData ChannelData `json:"channelData"`
Activity Activity `json:"activity"`
}
type ChannelData struct {
Channel Channel `json:"channel"`
}
type Channel struct {
ID string `json:"id"`
}
type Activity struct {
Type string `json:"type"`
Text string `json:"text"`
}
func NewMessage(isGroup bool, channelData ChannelData, activity Activity) *Message {
return &Message{
IsGroup: isGroup,
ChannelData: channelData,
Activity: activity,
}
}
func NewTextPost(channelId, text string) *Message {
return &Message{
IsGroup: true,
ChannelData: ChannelData{
Channel: Channel{
ID: channelId,
},
},
Activity: Activity{
Type: "message",
Text: text,
},
}
}
func (m *Message) ToJSON() (string, error) {
jsonBytes, err := json.Marshal(m)
if err != nil {
return "", err
}
return string(jsonBytes), nil
}