ui

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2024 License: MIT

README

Go Telegram Bot UI

The project is under development. API may be changed before v1.0.0 version.

Telegram Group

UI controls for telegram bot go-telegram/bot

  • datepicker
  • inline keyboard
  • paginator
  • slider
  • progress
  • dialog
  • timepicker (todo)

Feel to free to contribute and issues!

Getting Started

go get github.com/go-telegram/bot
go get github.com/go-telegram/ui

Important

UI components register own bot handlers on init. If you restart the bot instance, inline buttons in already opened components can't work.

For example, you can handle CallbackQuery in the default handler and send a message to the user.


func defaultHandler(ctx context.Context, b *bot.Bot, update bot.Update)  {
	if update.CallbackQuery != nil {
		b.SendMessage(ctx, &bot.SendMessageParams{
			ChatID:    update.CallbackQuery.Message.Chat.ID, 
			Text: "Bot was updated. Try to call calendar again",
		})  
	}
}
Live demo

You can run demo bot from examples folder.

Before start, you should set EXAMPLE_TELEGRAM_BOT_TOKEN environment variable to your bot token.

Also, you can try online version of this bot right now.

DatePicker

datepicker_1.png

  • custom localizations
  • set from/to dates
  • define include/exclude dates

Documentation

Inline Keyboard

inline_keyboard.png

Small helper for easy building of inline keyboard.

Documentation

Paginator

paginator.png

  • pass any slice of strings
  • set perPage value
  • set custom lines separator

Documentation

Slider

slider.png

  • pass slides with images and text

Documentation

Progress

progress.png

Progress bar for long tasks

Documentation

Dialog

dialog.gif

Simple dialogs

Documentation

Directories

Path Synopsis
keyboard

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL