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:
|
go:
|
||||||
- "1.12"
|
- "1.12"
|
||||||
script:
|
script:
|
||||||
- "make"
|
- "make test"
|
||||||
|
- "make build"
|
4
Makefile
4
Makefile
@ -15,6 +15,10 @@ clean:
|
|||||||
@echo Cleaning...
|
@echo Cleaning...
|
||||||
@rm -rf $(dir ${BIN})
|
@rm -rf $(dir ${BIN})
|
||||||
|
|
||||||
|
test:
|
||||||
|
@echo Testing...
|
||||||
|
@$(GO) test $(SRC)
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@$(BIN)
|
@$(BIN)
|
||||||
|
|
||||||
|
@ -31,6 +31,10 @@ func GetLatestAbyssQuotes() ([]BashQuote, error) {
|
|||||||
return extractQuotes("/abyss/", 25)
|
return extractQuotes("/abyss/", 25)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetRandomQuotes() ([]BashQuote, error) {
|
||||||
|
return extractQuotes("/random", 25)
|
||||||
|
}
|
||||||
|
|
||||||
func GetQuote(id int) (BashQuote, error) {
|
func GetQuote(id int) (BashQuote, error) {
|
||||||
quotes, err := extractQuotes(fmt.Sprintf("/quote/%d", id), 1)
|
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())
|
NewMessageWithQuotes(bot, update, &msgs, "Получаю свежие цитаты", update.Message.Command())
|
||||||
case "abyss":
|
case "abyss":
|
||||||
NewMessageWithQuotes(bot, update, &msgs, "Получаю цитаты из Бездны", update.Message.Command())
|
NewMessageWithQuotes(bot, update, &msgs, "Получаю цитаты из Бездны", update.Message.Command())
|
||||||
|
case "random":
|
||||||
|
NewMessageWithQuotes(bot, update, &msgs, "Получаю случайные цитаты", update.Message.Command())
|
||||||
default:
|
default:
|
||||||
msgs[len(msgs)-1].Text = "Как насчёт последних цитат? Используйте /latest"
|
msgs[len(msgs)-1].Text = "Как насчёт последних цитат? Используйте /latest"
|
||||||
}
|
}
|
||||||
@ -151,6 +153,8 @@ func NewMessageWithQuotes(
|
|||||||
items, err = GetLatestQuotes()
|
items, err = GetLatestQuotes()
|
||||||
case "abyss":
|
case "abyss":
|
||||||
items, err = GetLatestAbyssQuotes()
|
items, err = GetLatestAbyssQuotes()
|
||||||
|
case "random":
|
||||||
|
items, err = GetRandomQuotes()
|
||||||
default:
|
default:
|
||||||
items, err = GetLatestQuotes()
|
items, err = GetLatestQuotes()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user