mirror of
https://github.com/Neur0toxine/bash.im-telegram-bot.git
synced 2024-11-21 20:56:10 +03:00
Random quotes via /random, make test
This commit is contained in:
parent
f85a5ddd3a
commit
2ea533cad5
@ -3,4 +3,5 @@ language: go
|
||||
go:
|
||||
- "1.12"
|
||||
script:
|
||||
- "make"
|
||||
- "make test"
|
||||
- "make build"
|
4
Makefile
4
Makefile
@ -15,6 +15,10 @@ clean:
|
||||
@echo Cleaning...
|
||||
@rm -rf $(dir ${BIN})
|
||||
|
||||
test:
|
||||
@echo Testing...
|
||||
@$(GO) test $(SRC)
|
||||
|
||||
run:
|
||||
@$(BIN)
|
||||
|
||||
|
@ -31,6 +31,10 @@ func GetLatestAbyssQuotes() ([]BashQuote, error) {
|
||||
return extractQuotes("/abyss/", 25)
|
||||
}
|
||||
|
||||
func GetRandomQuotes() ([]BashQuote, error) {
|
||||
return extractQuotes("/random", 25)
|
||||
}
|
||||
|
||||
func GetQuote(id int) (BashQuote, error) {
|
||||
quotes, err := extractQuotes(fmt.Sprintf("/quote/%d", id), 1)
|
||||
|
||||
|
@ -115,6 +115,8 @@ func processUpdate(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
||||
NewMessageWithQuotes(bot, update, &msgs, "Получаю свежие цитаты", update.Message.Command())
|
||||
case "abyss":
|
||||
NewMessageWithQuotes(bot, update, &msgs, "Получаю цитаты из Бездны", update.Message.Command())
|
||||
case "random":
|
||||
NewMessageWithQuotes(bot, update, &msgs, "Получаю случайные цитаты", update.Message.Command())
|
||||
default:
|
||||
msgs[len(msgs)-1].Text = "Как насчёт последних цитат? Используйте /latest"
|
||||
}
|
||||
@ -151,6 +153,8 @@ func NewMessageWithQuotes(
|
||||
items, err = GetLatestQuotes()
|
||||
case "abyss":
|
||||
items, err = GetLatestAbyssQuotes()
|
||||
case "random":
|
||||
items, err = GetRandomQuotes()
|
||||
default:
|
||||
items, err = GetLatestQuotes()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user