utils

package
v0.0.0-...-66cef22 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ListenTimeout error
View Source
var Listening []Listeners

Functions

func Ask

func Ask(bot *gotgbot.Bot, text string, chat *gotgbot.Chat, user *gotgbot.User) *gotgbot.Message

Sends a text message to the given chat and listens for a reply.

bot - The bot that handles the conversation. text - Content of the request message to be sent. chat - The chat in which the conversion takes place user - The user expected to answer

func Contains

func Contains(l []string, v string) bool

Checks if a string slice contains an item.

func IsAdmin

func IsAdmin(u int64) bool

IsAdmin returns wether the user is a global admin(from env).

func ListenMessage

func ListenMessage(ctx context.Context, filter filters.Message) (*gotgbot.Message, error)

Listens for a message that matches the given filter.

ctx - Context with ideally a deadline set filter - The filter that the message must match (use customfilters package for prebuilts)

Returns either the message if it was received or a ListenTimeout error

func RandString

func RandString(length int) string

func RunListening

func RunListening(bot *gotgbot.Bot, update *ext.Context) error

Checks if update matches any saved listen filters

Types

type Listeners

type Listeners struct {
	// Filter which checks if message is a match
	Filter filters.Message
	// Function to be called if filter matches
	Callback handlers.Response
	// Unix timestamp at which the handler was added (Timeout after 300s)
	AddedTime int64
	// Channel to which message is passed
	Channel chan *gotgbot.Message
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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