telegram

package
v1.3.5-0...-9ad5f9a Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package telegram handles all Telegram-side logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFullUserZwsp

func GetFullUserZwsp(u *tgbotapi.User) string

GetFullUserZwsp returns both the Telegram user's first name and username, if available. Adds ZWSP to username to prevent username pinging across platform.

func GetFullUsername

func GetFullUsername(showZWSP bool, u *tgbotapi.User) string

GetFullUsername takes showZWSP condition and user then returns full username with or without ​.

func GetUsername

func GetUsername(showZWSP bool, u *tgbotapi.User) string

GetUsername takes showZWSP condition and user then returns username with or without ​.

func ZwspUsername

func ZwspUsername(u *tgbotapi.User) string

ZwspUsername adds a zero-width space after the first character of a Telegram user's username.

Types

type Client

type Client struct {
	Settings      *internal.TelegramSettings
	IRCSettings   *internal.IRCSettings
	ImgurSettings *internal.ImgurSettings
	// contains filtered or unexported fields
}

Client contains information for the Telegram bridge, including the TelegramSettings needed to run the bot

func NewClient

func NewClient(settings *internal.TelegramSettings, ircsettings *internal.IRCSettings, imgur *internal.ImgurSettings, tgapi *tgbotapi.BotAPI, logger internal.DebugLogger) *Client

NewClient creates a new Telegram bot client

func (*Client) SendMessage

func (tg *Client) SendMessage(msg string)

SendMessage sends a message to the Telegram channel specified in the settings

func (*Client) StartBot

func (tg *Client) StartBot(errChan chan<- error, sendMessage func(string))

StartBot adds necessary handlers to the client and then connects, returning any errors that occur

type Handler

type Handler = func(tg *Client, u tgbotapi.Update)

Handler specifies a function that handles a Telegram update. In this case, we take a Telegram client and update object, where the specific Handler will "handle" the given event.

Jump to

Keyboard shortcuts

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