/
respone-messages.go
107 lines (99 loc) · 3.98 KB
/
respone-messages.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package handler
import (
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
)
func CreateStartMessage(chatId int64) tgbotapi.MessageConfig {
msg := tgbotapi.NewMessage(chatId, "Hi!\nChoose one these options below:")
msg.ParseMode = tgbotapi.ModeHTML
aboutButton := tgbotapi.NewKeyboardButton(AboutMessage)
loginButton := tgbotapi.NewKeyboardButton(LogInMessage)
keyboard := tgbotapi.NewReplyKeyboard(
tgbotapi.NewKeyboardButtonRow(loginButton, aboutButton),
)
keyboard.OneTimeKeyboard = true
msg.ReplyMarkup = keyboard
return msg
}
func CreateAboutUsMessage(chatId int64) tgbotapi.MessageConfig {
msg := tgbotapi.NewMessage(chatId, "blah blah blah blah\nblah blah blah blah\n@pooria2 is creator :D")
msg.ParseMode = tgbotapi.ModeHTML
backButton := tgbotapi.NewKeyboardButton(BackMessage)
keyboard := tgbotapi.NewReplyKeyboard(
tgbotapi.NewKeyboardButtonRow(backButton),
)
keyboard.OneTimeKeyboard = true
msg.ReplyMarkup = keyboard
return msg
}
func CreateLoginMessage(chatId int64) tgbotapi.MessageConfig {
if len(members.GetTags(chatId)) == 0 {
msg := tgbotapi.NewMessage(
chatId,
"Send your account tag.\nYou can copy your tag from your clash royale profile, under your username",
)
msg.ParseMode = tgbotapi.ModeHTML
msg.ReplyMarkup = tgbotapi.NewRemoveKeyboard(true)
return msg
}
var buttons [][]tgbotapi.KeyboardButton
for _, tag := range members.GetTags(chatId) {
buttons = append(buttons, tgbotapi.NewKeyboardButtonRow(tgbotapi.NewKeyboardButton(tag)))
}
var msg = tgbotapi.NewMessage(chatId,
"Choose a tag from list below or send a new tag:",
)
msg.ParseMode = tgbotapi.ModeHTML
keyboard := tgbotapi.NewReplyKeyboard(buttons...)
keyboard.OneTimeKeyboard = true
msg.ReplyMarkup = keyboard
return msg
}
func CreateHomePageMessage(chatId int64, messageId int) tgbotapi.Chattable {
tag := members.GetCurrentTag(chatId)
p, _ := royaleClient.Player(tag)
textMessage := "Dear " + members.GetUser(chatId).FirstName + "!\n" + "You are logged in as " + p.Name
textMessage += ". Choose one of options below to see result;"
textMessage += "\nAnd don't forget!! If you like this bot please share "
textMessage += "for your clan mates and send me your suggestions and feedback with /about_us command"
newButton1 := tgbotapi.NewInlineKeyboardButtonData("Profile info", ProfileInfoQuery)
newButton2 := tgbotapi.NewInlineKeyboardButtonData("Game data stats", PlayerStatsQuery)
newButton3 := tgbotapi.NewInlineKeyboardButtonData("Change Account", ChangeAccountQuery)
keyboard := tgbotapi.NewInlineKeyboardMarkup(
tgbotapi.NewInlineKeyboardRow(newButton1, newButton2),
tgbotapi.NewInlineKeyboardRow(newButton3),
)
if messageId != -1 {
msg := tgbotapi.NewEditMessageText(chatId, messageId, textMessage)
msg.ReplyMarkup = &keyboard
return msg
}
msg := tgbotapi.NewMessage(chatId, textMessage)
msg.ReplyMarkup = keyboard
return msg
}
func CreateProfileInfoMessage(chatId int64, messageID int) tgbotapi.EditMessageTextConfig {
newButton := tgbotapi.NewInlineKeyboardButtonData("Back", BackMessage)
keyboard := tgbotapi.NewInlineKeyboardMarkup(
tgbotapi.NewInlineKeyboardRow(newButton),
)
p, _ := royaleClient.Player(members.GetCurrentTag(chatId))
msg := tgbotapi.NewEditMessageText(chatId, messageID, p.GetPlayerProfileInfo())
msg.ReplyMarkup = &keyboard
return msg
}
func CreateProfileStatsMessage(chatId int64, messageID int) tgbotapi.EditMessageTextConfig {
newButton := tgbotapi.NewInlineKeyboardButtonData("Back", BackMessage)
keyboard := tgbotapi.NewInlineKeyboardMarkup(
tgbotapi.NewInlineKeyboardRow(newButton),
)
p, _ := royaleClient.Player(members.GetCurrentTag(chatId))
b, _ := royaleClient.BattleLog(members.GetCurrentTag(chatId))
msg := tgbotapi.NewEditMessageText(chatId, messageID, b.GetPlayerStats(p.TotalWinPercentage()))
msg.ReplyMarkup = &keyboard
return msg
}
func SendLoadingMessage(chatId int64) (tgbotapi.Message, error) {
msg := tgbotapi.NewMessage(chatId, "Loading...")
msg.ReplyMarkup = tgbotapi.NewRemoveKeyboard(false)
return Bot.Send(msg)
}