forked from bots-go-framework/bots-fw
/
models.go
68 lines (56 loc) · 1.63 KB
/
models.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package viber
import (
"fmt"
"github.com/strongo/app/user"
"github.com/strongo/bots-framework/core"
"time"
)
const (
//ViberChatKind = "ViberChat"
//ViberUserKind = "ViberUser"
// UserChatKind is user chat kind name
UserChatKind = "ViberUserChat"
)
// UserChatEntity is bot chat entity for Viber
type UserChatEntity struct {
bots.BotChatEntity
//ViberUserID string `datastore:",noindex"` // Duplicate of key.StringID(), required for GetBotUserStringID()
//UserName string `datastore:",noindex"`
//Avatar string `datastore:",noindex"`
}
var _ bots.BotUser = (*UserChatEntity)(nil)
var _ bots.BotChat = (*UserChatEntity)(nil)
//type ViberUser struct { //TODO: Get rid of the entity. Move props like Name to ViberChat entity.
// bots.BotUserEntity
// //TgChatID int64
//}
//var _ bots.BotUser = (*ViberUser)(nil)
//type ViberChat struct {
// bots.BotChatEntity
// ViberUserID string
//}
//
//var _ bots.BotChat = (*ViberChat)(nil)
// NewUserChat creates new UserChatEntity
func NewUserChat() UserChatEntity {
return UserChatEntity{
BotChatEntity: bots.BotChatEntity{
BotEntity: bots.BotEntity{OwnedByUserWithIntID: user.NewOwnedByUserWithIntID(0, time.Now())},
},
}
}
// SetAppUserIntID sets app user int ID
func (chat *UserChatEntity) SetAppUserIntID(id int64) {
chat.AppUserIntID = id
}
//func (chat *ViberChat) GetBotUserStringID() string {
// return chat.ViberUserID
//}
// SetBotUserID sets bot user ID
func (chat *UserChatEntity) SetBotUserID(id interface{}) {
if _, ok := id.(string); ok {
// Ignore as stored in the key. chat.ViberUserID = stringID
return
}
panic(fmt.Sprintf("Expected string, got: %T=%v", id, id))
}