summaryrefslogtreecommitdiff
path: root/internal/data/chat.go
blob: ae5dc67e4a4a071ea26e0cad8e053bb861db203b (plain)
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
package data

import (
	"github.com/kyren223/eko/pkg/snowflake"
	"github.com/kyren223/eko/pkg/utils"
)

// Represents an Eko Network, equivalent to a "discord server".
type Network struct {
	id          snowflake.ID
	name        string
	frequencies []snowflake.ID
}

// Represents an Eko Frequency, equivalent to a "discord channel" within a "discord server".
type Frequency struct {
	id   snowflake.ID
	name string
}

// Represents an Eko Signal, equivalent to a "discord message" between only 2 people.
type Signal struct {
	userId1 snowflake.ID
	userId2 snowflake.ID
}

// Represents a message
type Message struct {
	Id          snowflake.ID
	SenderId    snowflake.ID
	FrequencyId snowflake.ID
	NetworkId   snowflake.ID
	Contents    string
}

func (a Message) CmpTimestamp(b Message) int {
	cmpTime := a.Id.Time() - b.Id.Time()
	if cmpTime != 0 {
		return int(utils.Clamp(cmpTime, -1, 1))
	}
	cmpStep := a.Id.Step() - b.Id.Step()
	if cmpStep != 0 {
		return int(utils.Clamp(cmpStep, -1, 1))
	}
	cmpNode := a.Id.Node() - b.Id.Node()
	if cmpNode != 0 {
		return int(utils.Clamp(cmpNode, -1, 1))
	}
	return 0
}

// Represents an Eko User
type User struct {
	id snowflake.ID
}