Categorygithub.com/rusq/tbcomctl/v4
modulepackage
4.0.1
Repository: https://github.com/rusq/tbcomctl.git
Documentation: pkg.go.dev

# README

=================================== Common Controls Library for Telebot

Library provides common controls to use with Telebot_ library.

Controls:

  • Picklist - add inline keyboard to bots messages.
  • Post Buttons - add buttons to your channel posts.
  • Rating - rating buttons for channel posts.
  • Keyboard - a convenient way to create a keyboard.
  • Input - ask user for input and process the answer in OnText.

Abstractions:

  • Form (combines other controls into a pipeline, see examples_)

Utilities:

  • Subscription - check if user is subscribed to the channels of interest.
  • Middleware - some helpful middleware functions.
  • Helper functions for logging, etc.

Breaking Changes in V4

Controls now operate on Interfaces defined in interface.go rather than functions. There's a new convenience structure TVC which can be used to wrap the functions when updating to v4.

See examples_ for usage.

Installation

For Telebot_ v3::

go get github.com/rusq/tbcomctl/v4

For Telebot_ v2::

go get github.com/rusq/tbcomctl // or go get github.com/rusq/tbcomctl/v2

v2 is not actively developed, but you're more than welcome to submit your PRs.

Usage

For usage - see examples_.

.. _Telebot: https://github.com/tucnak/telebot .. _examples: examples

# Packages

No description provided by the author

# Functions

ButtonMarkup returns the button markup for the message.
No description provided by the author
ChatInfo returns the chat info.
ControllerFromCtx returns the controller from the context.
GetLogger returns current logger.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewControllerChain returns the controller chain.
NewForm creates a new Form from a set of Controllers.
NewInput text creates a new text input, optionally chaining with the `next` handler.
NewInputError returns an input error with msg.
NewIntputText is the shortcut to create the Input instance with static text.
No description provided by the author
NewMessage creates new Message Controller.
NewMessageText is a convenience wrapper for NewMessage with a fixed text.
NewPicklist creates a new picklist.
NewPostButtons creates an instance of PostButtons.
No description provided by the author
NewStaticTVC is a convenience constructor for TVC (TextValueCallbacker) with static text and values.
NewSubChecker creates new subscription checker that checks the subscription on the desired channels.
NewTexter wraps the msg returning a Texter.
NoDebugLogger switches off debug messages.
NoLogging switches off default logging, if you're brave.
Nvlstring returns the first non-empty string from the list.
No description provided by the author
No description provided by the author
PickOptBtnPattern sets the inline markup button pattern.
PickOptDefaultSendOptions allows to set the default send options.
No description provided by the author
No description provided by the author
No description provided by the author
PickOptNoUpdate sets the No Update option.
No description provided by the author
No description provided by the author
PickOptRemoveButtons set the Remove Buttons option.
Printer returns the Message Printer for the desired lang.
PrinterContext returns the Message Printer set to the language of the sender.
PrivateOnly is the middleware that restricts the handler to only private messages.
PrivateOnlyMsg returns the handler that will reject non-private messages (eg.
RBOptShowPostRating enables counter of total upvotes/downvotes.
RBOptShowVoteCounter enables post rating between up/down vote buttons.
No description provided by the author
No description provided by the author
Sdump dumps the structure.
SenderInfo is the convenience function to log the sender info in the context.
SetDebugLogger sets the debug logger which is used to output debug messages, if you must.
SetLogger sets the current logger.
Userinfo returns the user info.
WithController adds the controller to the context.

# Constants

FallbackLang is the default fallback language.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
there has been no change to the selection.
error of this type will ask user to retry the selection or input.
tell user that there was an input error (user-error).

# Variables

lint:ignore ST1012 it is what it is.
No description provided by the author
ErrNoChange should be returned if the user picked the same value as before, and no update needed.
ErrRetry should be returned by CallbackFunc if the retry should be performed.

# Structs

Button is the control button.
Error is the type of error returned by the input-processing callback functions.
Form is an abstraction that presents controllers in a way of a form.
No description provided by the author
No description provided by the author
No description provided by the author
Message is the controller that sends a message.
No description provided by the author
No description provided by the author
Rating is a struct for attaching post rating.
StoredMessage represents the stored message in the database.
SubChecker is controller to check the chat subscription.
TVC is an implementation of TextValuerCallbacker.

# Interfaces

Callbacker defines the interface for the callback function.
Controller is the interface that some common controls implement.
ErrorHandler is an optional interface for some controls, that the caller might implement so that errors occurred while handling the Callback could be handled by the caller as well.
Logger is the interface for logging.
TextCallbacker combines Texter and Callbacker interfaces.
Texter is the interface that contains only the method to return the Message Text.
TextValueCallbacker combines Texter, Valuer and Callbacker interfaces.
TextValuer combines Texter and Valuer interfaces.
Valuer is the interface.

# Type aliases

No description provided by the author
ErrType is the type of error returned by the callback functions.
HandleContextFunc is the callback function that is being called within controller callbacks.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
RatingFunc is the function called by callback, given the message, user and the button index it should update the records and return the new buttons with updated values for the posting, it must maintain count of votes inhouse.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author