aboutsummaryrefslogtreecommitdiff
path: root/message.go
blob: 739d59c91c45a1e34fdbb8404886fbbf926b011a (plain) (blame)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
package tamtam

import "github.com/neonxp/tamtam/schemes"

type Message struct {
	userID  int64
	chatID  int64
	message *schemes.NewMessageBody
}

func NewMessage() *Message {
	return &Message{userID: 0, chatID: 0, message: &schemes.NewMessageBody{Attachments: []interface{}{}}}
}

func (m *Message) SetUser(userID int64) *Message {
	m.userID = userID
	return m
}
func (m *Message) SetChat(chatID int64) *Message {
	m.chatID = chatID
	return m
}

func (m *Message) SetText(text string) *Message {
	m.message.Text = text
	return m
}

func (m *Message) SetNotify(notify bool) *Message {
	m.message.Notify = notify
	return m
}

func (m *Message) AddKeyboard(keyboard *Keyboard) *Message {
	m.message.Attachments = append(m.message.Attachments, schemes.NewInlineKeyboardAttachmentRequest(keyboard.Build()))
	return m
}

func (m *Message) AddPhoto(photo *schemes.PhotoTokens) *Message {
	m.message.Attachments = append(m.message.Attachments, schemes.NewPhotoAttachmentRequest(schemes.PhotoAttachmentRequestPayload{
		Photos: photo.Photos,
	}))
	return m
}

func (m *Message) AddAudio(audio *schemes.UploadedInfo) *Message {
	m.message.Attachments = append(m.message.Attachments, schemes.NewAudioAttachmentRequest(*audio))
	return m
}

func (m *Message) AddVideo(video *schemes.UploadedInfo) *Message {
	m.message.Attachments = append(m.message.Attachments, schemes.NewVideoAttachmentRequest(*video))
	return m
}

func (m *Message) AddFile(file *schemes.UploadedInfo) *Message {
	m.message.Attachments = append(m.message.Attachments, schemes.NewFileAttachmentRequest(*file))
	return m
}

func (m *Message) AddLocation(lat float64, lon float64) *Message {
	m.message.Attachments = append(m.message.Attachments, schemes.NewLocationAttachmentRequest(lat, lon))
	return m
}

func (m *Message) AddContact(name string, contactID int64, vcfInfo string, vcfPhone string) *Message {
	m.message.Attachments = append(m.message.Attachments, schemes.NewContactAttachmentRequest(schemes.ContactAttachmentRequestPayload{
		Name:      name,
		ContactId: contactID,
		VcfInfo:   vcfInfo,
		VcfPhone:  vcfPhone,
	}))
	return m
}

func (m *Message) AddSticker(code string) *Message {
	m.message.Attachments = append(m.message.Attachments, schemes.NewStickerAttachmentRequest(schemes.StickerAttachmentRequestPayload{
		Code: code,
	}))
	return m
}