29 lines
522 B
Go
29 lines
522 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"go.wit.com/lib/protobuf/chatpb"
|
|
"go.wit.com/log"
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
)
|
|
|
|
func doNewChat() {
|
|
if len(argv.NewChat) != 2 {
|
|
log.Error(fmt.Errorf("expected 2 arguments for --new-chat"))
|
|
return
|
|
}
|
|
uuid := argv.NewChat[0]
|
|
topic := argv.NewChat[1]
|
|
|
|
chat := &chatpb.Chat{
|
|
Uuid: uuid,
|
|
ChatName: topic,
|
|
Ctime: timestamppb.Now(),
|
|
}
|
|
|
|
me.chats.Chats = append(me.chats.Chats, chat)
|
|
me.chats.ConfigSave()
|
|
log.Info("created new chat for", uuid)
|
|
}
|