telegram

package
v0.0.0-...-57913f4 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnswerCallback

func AnswerCallback(upd tgbotapi.Update, bot *tgbotapi.BotAPI, text string)

AnswerCallback answers the callback query made in the provided update. Note: If text is not an empty string, it will be displayed to the user who initiated the callback query.

func BanUser

func BanUser(TgID int, bot *tgbotapi.BotAPI) error

BanUser is a helper function to ban a user in the main chat based on their Telegram ID

func CallbackInfo

func CallbackInfo(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

CallbackInfo is a callback handler to update a find by alias request after a user button is clicked

func CheckNewUsers

func CheckNewUsers(bot *tgbotapi.BotAPI)

CheckNewUsers checks to see if any recently joined members have been in the chat for too long

func ConfirmBan

func ConfirmBan(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

ConfirmBan handles the callback when the user presses the final ban confirmation button

func DisplayAliases

func DisplayAliases(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

DisplayAliases is a callback handler to update a get user info response to add all known user aliases

func DisplayWarnings

func DisplayWarnings(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

DisplayWarnings is a callback handler to update a get user info response to add warnings for the user

func FindUserByUserID

func FindUserByUserID(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

FindUserByUserID gets user information by telegram ID

func FindUserByUsername

func FindUserByUsername(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

FindUserByUsername finds user information by username

func GetBotStatus

func GetBotStatus(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

GetBotStatus returns uptime of the bot

func GetMemberFromID

func GetMemberFromID(bot *tgbotapi.BotAPI, userID int) (tgbotapi.ChatMember, error)

GetMemberFromID gets information about a user from their telegram ID

func GetUserInfoResponse

func GetUserInfoResponse(user *models.ChatUser) tgbotapi.MessageConfig

GetUserInfoResponse is a helper method to generate the response object for the info requests

func HandleUsers

func HandleUsers(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

HandleUsers reads non-command messages to record user information/changes

func InitBot

func InitBot(botToken string)

InitBot starts up the bot and processes incoming updates

func InitiateUser

func InitiateUser(upd tgbotapi.Update, bot *tgbotapi.BotAPI, newUser tgbotapi.User)

InitiateUser checks to see if a user is a real person or not by making them talk to the bot

func LogBotAction

func LogBotAction(bot *tgbotapi.BotAPI, botAction BotAction)

LogBotAction sends a message to the bot logs channel

func LogCallback

func LogCallback(upd tgbotapi.Update, callback tgbotapi.CallbackConfig)

LogCallback logs information from a processed callback

func LogCommand

func LogCommand(upd tgbotapi.Update, err error)

LogCommand logs information from a processed command

func LogMessage

func LogMessage(upd tgbotapi.Update)

LogMessage logs information from a processed message

func LookupAlias

func LookupAlias(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

LookupAlias finds a user even if only part of one of their aliases is provided

func MainChatHelp

func MainChatHelp(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

MainChatHelp lists commands available in the main chat

func MakeAliasInlineKeyboard

func MakeAliasInlineKeyboard(aliases []models.ChatUser) tgbotapi.InlineKeyboardMarkup

MakeAliasInlineKeyboard is a helper method to generate the buttons for the lookup by alias command

func MakeBanConfirmInlineKeyboard

func MakeBanConfirmInlineKeyboard(userID int64) tgbotapi.InlineKeyboardMarkup

MakeBanConfirmInlineKeyboard is a helper method to generate the buttons for the final ban request

func MakeBanInlineKeyboard

func MakeBanInlineKeyboard(userID int64) tgbotapi.InlineKeyboardMarkup

MakeBanInlineKeyboard is a helper method to generate the buttons for a pre ban request

func MakeCaptchaInlineKeyboard

func MakeCaptchaInlineKeyboard(userID int) tgbotapi.InlineKeyboardMarkup

MakeCaptchaInlineKeyboard is a helper method for solving captchas

func MakeInitiateUserInlineKeyboard

func MakeInitiateUserInlineKeyboard(userID int) tgbotapi.InlineKeyboardMarkup

MakeInitiateUserInlineKeyboard is a helper method to generate the buttons for a user initiation

func MakeReturnToChatInlineKeyboard

func MakeReturnToChatInlineKeyboard(userID int) tgbotapi.InlineKeyboardMarkup

MakeReturnToChatInlineKeyboard is a helper method to generate the button to go back to @rfurry

func MakeUserInfoInlineKeyboard

func MakeUserInfoInlineKeyboard(userID int64) tgbotapi.InlineKeyboardMarkup

MakeUserInfoInlineKeyboard is a helper method to generate the buttons for an initial info request

func MakeUserInfoInlineKeyboardRefreshAliasButton

func MakeUserInfoInlineKeyboardRefreshAliasButton(userID int64, curAliasPage int64, aliasPagesTotal int64) tgbotapi.InlineKeyboardMarkup

MakeUserInfoInlineKeyboardRefreshAliasButton is a helper method to generate the buttons for an info request after view aliases button is pressed

func MakeUserInfoInlineKeyboardRefreshWarnButton

func MakeUserInfoInlineKeyboardRefreshWarnButton(userID int64) tgbotapi.InlineKeyboardMarkup

MakeUserInfoInlineKeyboardRefreshWarnButton is a helper method to generate the buttons for an info request after view warnings button is pressed

func ModChatHelp

func ModChatHelp(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

ModChatHelp lists commands available in the mod chat

func PreBan

func PreBan(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

PreBan handles the first step in the ban process by displaying the target to a user

func PreConfirmBan

func PreConfirmBan(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

PreConfirmBan handles the callback when a user presses the first confirm ban button

func PrivateChatHelp

func PrivateChatHelp(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

PrivateChatHelp lists commands available in private chats

func ProcessCallback

func ProcessCallback(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

ProcessCallback checks the list of recognized callbacks to see if any are found

func ProcessMessage

func ProcessMessage(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

ProcessMessage logs the message and checks the list of recognized commands to see if any are found

func Register

func Register(regexIn string, chanIn int64, handleFunc func(tgbotapi.Update, *tgbotapi.BotAPI))

Register adds a regex pattern to the list of recognized commands

func RegisterCallback

func RegisterCallback(regexIn string, handleFunc func(tgbotapi.Update, *tgbotapi.BotAPI))

RegisterCallback adds a regex pattern to the list of recognized callbacks

func ResolveAlert

func ResolveAlert(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

ResolveAlert deletes messages which were created during the /mods command

func Start

func Start(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

Start is a command used when the bot is first run If the user is being verified, it will act differently

func SummonMods

func SummonMods(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

SummonMods summons moderators to a chat

func TestCmd

func TestCmd(updateIn tgbotapi.Update, botIn *tgbotapi.BotAPI)

TestCmd pings the bot to make sure it is running

func ToggleMods

func ToggleMods(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

ToggleMods handles toggling of a user's ability to use /mods

func VerifyCorrect

func VerifyCorrect(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

VerifyCorrect verifies a user who solves the captcha

func VerifyIncorrect

func VerifyIncorrect(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

VerifyIncorrect resets the captcha when a user picks the wrong answer

func WarnUserByID

func WarnUserByID(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

WarnUserByID warns a user by telegram ID

func WarnUserByUsername

func WarnUserByUsername(upd tgbotapi.Update, bot *tgbotapi.BotAPI)

WarnUserByUsername warns a user by username

Types

type BotAction

type BotAction struct {
	Type           BotActionType
	InvokerUserID  int
	ReceiverUserID int
}

BotAction represents an action taken by the bot

type BotActionType

type BotActionType string

BotActionType indicates the type of action the bot is taking

const (
	// BotActionBan removes a user
	BotActionBan BotActionType = "BAN"
	//BotActionVerify verifies a user
	BotActionVerify BotActionType = "VERIFY"
	//BotActionRemovePermissions removes all permissions from a user
	BotActionRemovePermissions BotActionType = "REMOVEPERMISSIONS"
)

type BotCommand

type BotCommand struct {
	MatchCmd   *regexp.Regexp
	Chan       int64
	HandleFunc func(tgbotapi.Update, *tgbotapi.BotAPI)
}

BotCommand represents a command the bot receives

type NewUser

type NewUser struct {
	JoinTime    time.Time
	JoinMessage int
	CaptchaID   string
	Attempts    int
}

NewUser captures data involving a new person joining the chat

Jump to

Keyboard shortcuts

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