Exemplo n.º 1
0
func instPic(bot tgbot.TgBot, msg tgbot.Message, text string) *string {
	httpClient := http.DefaultClient
	hexapicAPI := hexapic.NewSearchApi(instagramid, httpClient)
	hexapicAPI.Count = 4
	var imgs []image.Image

	bot.Answer(msg).
		Action(tgbot.UploadPhoto).
		End()

	imgs = hexapicAPI.SearchByTag("cat")
	img := hexapic.GenerateCollage(imgs, 2, 2)
	keylayout := [][]string{{"cat", "dog"}, {"nya", "chick"}}
	rkm := tgbot.ReplyKeyboardMarkup{
		Keyboard:        keylayout,
		ResizeKeyboard:  true,
		OneTimeKeyboard: true,
		Selective:       false,
	}
	caption := "Guess the image!"
	bot.Answer(msg).
		Photo(img).
		Caption(caption).
		Keyboard(rkm).
		End()
	// bot.SendPhotoWithKeyboard(msg.Chat.ID, img, &caption, nil, rkm)
	return nil
}
Exemplo n.º 2
0
func generateImage(question Question, httpClient *http.Client) (img image.Image) {
	hexapicAPI := hexapic.NewSearchApi(global.InstagramClientID, httpClient)
	hexapicAPI.Count = 4
	imgs := hexapicAPI.SearchByTag(question.Answer)
	img = hexapic.GenerateCollage(imgs, 2, 2)
	return
}