Documentation ¶
Index ¶
- Constants
- Variables
- func BuildKeyboard(buttons []db.Button) [][]gotgbot.InlineKeyboardButton
- func ChunkKeyboardSlices(slice []gotgbot.InlineKeyboardButton, chunkSize int) (chunks [][]gotgbot.InlineKeyboardButton)
- func ConvertButtonV2ToDbButton(buttons []tgmd2html.ButtonV2) (btns []db.Button)
- func ExtractAdminUpdateStatusChange(u *gotgbot.ChatMemberUpdated) bool
- func ExtractJoinLeftStatusChange(u *gotgbot.ChatMemberUpdated) (bool, bool)
- func FormattingReplacer(b *gotgbot.Bot, chat *gotgbot.Chat, user *gotgbot.User, oldMsg string, ...) (res string, btns []db.Button)
- func GetFullName(FirstName, LastName string) string
- func GetLangFormat(langCode string) string
- func GetMessageLinkFromMessageId(chat *gotgbot.Chat, messageId int64) (messageLink string)
- func GetNoteAndFilterType(msg *gotgbot.Message, isFilter bool) (keyWord, fileid, text string, dataType int, buttons []db.Button, ...)
- func GetWelcomeType(msg *gotgbot.Message, greetingType string) (text string, dataType int, fileid string, buttons []db.Button, errorMsg string)
- func InitButtons(b *gotgbot.Bot, chatId, userId int64) gotgbot.InlineKeyboardMarkup
- func InlineKeyboardMarkupToTgmd2htmlButtonV2(replyMarkup *gotgbot.InlineKeyboardMarkup) (btns []tgmd2html.ButtonV2)
- func IsUserConnected(b *gotgbot.Bot, ctx *ext.Context, chatAdmin, botAdmin bool) (chat *gotgbot.Chat)
- func MakeLanguageKeyboard() [][]gotgbot.InlineKeyboardButton
- func MentionHtml(userId int64, name string) string
- func MentionUrl(url, name string) string
- func PasteToNekoBin(text string) (pasted bool, key string)
- func ReverseHTML2MD(text string) string
- func RevertButtons(buttons []db.Button) string
- func SendFilter(b *gotgbot.Bot, ctx *ext.Context, filterData *db.ChatFilters, replyMsgId int64) (*gotgbot.Message, error)
- func SendNote(b *gotgbot.Bot, chat *gotgbot.Chat, ctx *ext.Context, noteData *db.ChatNotes, ...) (*gotgbot.Message, error)
- func Shtml() *gotgbot.SendMessageOpts
- func Smarkdown() *gotgbot.SendMessageOpts
- func SplitMessage(msg string) []string
Constants ¶
const ( Markdown = "Markdown" HTML = "HTML" None = "None" MaxMessageLength int = 4096 )
NOTE: small helper functions constants
Variables ¶
var FiltersEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, filterData db.ChatFilters, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, noFormat, noNotif bool) (*gotgbot.Message, error){ db.TEXT: func(b *gotgbot.Bot, ctx *ext.Context, filterData db.ChatFilters, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, noFormat, noNotif bool) (*gotgbot.Message, error) { formatMode := HTML if noFormat { formatMode = None } return b.SendMessage( ctx.Update.Message.Chat.Id, filterData.FilterReply, &gotgbot.SendMessageOpts{ ParseMode: formatMode, DisableWebPagePreview: true, ReplyToMessageId: replyMsgId, ReplyMarkup: keyb, DisableNotification: noNotif, MessageThreadId: ctx.Update.Message.MessageThreadId, }, ) }, db.STICKER: func(b *gotgbot.Bot, ctx *ext.Context, filterData db.ChatFilters, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, noFormat, noNotif bool) (*gotgbot.Message, error) { return b.SendSticker( ctx.Update.Message.Chat.Id, filterData.FileID, &gotgbot.SendStickerOpts{ ReplyToMessageId: replyMsgId, ReplyMarkup: keyb, DisableNotification: noNotif, MessageThreadId: ctx.Update.Message.MessageThreadId, }, ) }, db.DOCUMENT: func(b *gotgbot.Bot, ctx *ext.Context, filterData db.ChatFilters, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, noFormat, noNotif bool) (*gotgbot.Message, error) { formatMode := HTML if noFormat { formatMode = None } return b.SendDocument( ctx.Update.Message.Chat.Id, filterData.FileID, &gotgbot.SendDocumentOpts{ ReplyToMessageId: replyMsgId, ParseMode: formatMode, ReplyMarkup: keyb, Caption: filterData.FilterReply, DisableNotification: noNotif, MessageThreadId: ctx.Update.Message.MessageThreadId, }, ) }, db.PHOTO: func(b *gotgbot.Bot, ctx *ext.Context, filterData db.ChatFilters, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, noFormat, noNotif bool) (*gotgbot.Message, error) { formatMode := HTML if noFormat { formatMode = None } return b.SendPhoto( ctx.Update.Message.Chat.Id, filterData.FileID, &gotgbot.SendPhotoOpts{ ReplyToMessageId: replyMsgId, ParseMode: formatMode, ReplyMarkup: keyb, Caption: filterData.FilterReply, DisableNotification: noNotif, MessageThreadId: ctx.Update.Message.MessageThreadId, }, ) }, db.AUDIO: func(b *gotgbot.Bot, ctx *ext.Context, filterData db.ChatFilters, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, noFormat, noNotif bool) (*gotgbot.Message, error) { formatMode := HTML if noFormat { formatMode = None } return b.SendAudio( ctx.Update.Message.Chat.Id, filterData.FileID, &gotgbot.SendAudioOpts{ ReplyToMessageId: replyMsgId, ParseMode: formatMode, ReplyMarkup: keyb, Caption: filterData.FilterReply, DisableNotification: noNotif, MessageThreadId: ctx.Update.Message.MessageThreadId, }, ) }, db.VOICE: func(b *gotgbot.Bot, ctx *ext.Context, filterData db.ChatFilters, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, noFormat, noNotif bool) (*gotgbot.Message, error) { formatMode := HTML if noFormat { formatMode = None } return b.SendVoice( ctx.Update.Message.Chat.Id, filterData.FileID, &gotgbot.SendVoiceOpts{ ReplyToMessageId: replyMsgId, ParseMode: formatMode, ReplyMarkup: keyb, Caption: filterData.FilterReply, DisableNotification: noNotif, MessageThreadId: ctx.Update.Message.MessageThreadId, }, ) }, db.VIDEO: func(b *gotgbot.Bot, ctx *ext.Context, filterData db.ChatFilters, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, noFormat, noNotif bool) (*gotgbot.Message, error) { formatMode := HTML if noFormat { formatMode = None } return b.SendVideo( ctx.Update.Message.Chat.Id, filterData.FileID, &gotgbot.SendVideoOpts{ ReplyToMessageId: replyMsgId, ParseMode: formatMode, ReplyMarkup: keyb, Caption: filterData.FilterReply, DisableNotification: noNotif, MessageThreadId: ctx.Update.Message.MessageThreadId, }, ) }, db.VideoNote: func(b *gotgbot.Bot, ctx *ext.Context, filterData db.ChatFilters, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, noFormat, noNotif bool) (*gotgbot.Message, error) { return b.SendVideoNote( ctx.Update.Message.Chat.Id, filterData.FileID, &gotgbot.SendVideoNoteOpts{ ReplyToMessageId: replyMsgId, ReplyMarkup: keyb, DisableNotification: noNotif, MessageThreadId: ctx.Update.Message.MessageThreadId, }, ) }, }
FiltersEnumFuncMap A rather very complicated FiltersEnumFuncMap Variable made by me to send filters in an appropriate way
var GreetingsEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, msg, fileID string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error){ db.TEXT: func(b *gotgbot.Bot, ctx *ext.Context, msg, _ string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error) { return b.SendMessage( ctx.EffectiveChat.Id, msg, &gotgbot.SendMessageOpts{ ParseMode: HTML, DisableWebPagePreview: true, ReplyMarkup: keyb, }, ) }, db.STICKER: func(b *gotgbot.Bot, ctx *ext.Context, _, fileID string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error) { return b.SendSticker( ctx.EffectiveChat.Id, fileID, &gotgbot.SendStickerOpts{ ReplyMarkup: keyb, MessageThreadId: ctx.EffectiveMessage.MessageThreadId, }, ) }, db.DOCUMENT: func(b *gotgbot.Bot, ctx *ext.Context, msg, fileID string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error) { return b.SendDocument( ctx.EffectiveChat.Id, fileID, &gotgbot.SendDocumentOpts{ ParseMode: HTML, ReplyMarkup: keyb, Caption: msg, MessageThreadId: ctx.EffectiveMessage.MessageThreadId, }, ) }, db.PHOTO: func(b *gotgbot.Bot, ctx *ext.Context, msg, fileID string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error) { return b.SendPhoto( ctx.EffectiveChat.Id, fileID, &gotgbot.SendPhotoOpts{ ParseMode: HTML, ReplyMarkup: keyb, Caption: msg, MessageThreadId: ctx.EffectiveMessage.MessageThreadId, }, ) }, db.AUDIO: func(b *gotgbot.Bot, ctx *ext.Context, msg, fileID string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error) { return b.SendAudio( ctx.EffectiveChat.Id, fileID, &gotgbot.SendAudioOpts{ ParseMode: HTML, ReplyMarkup: keyb, Caption: msg, MessageThreadId: ctx.EffectiveMessage.MessageThreadId, }, ) }, db.VOICE: func(b *gotgbot.Bot, ctx *ext.Context, msg, fileID string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error) { return b.SendVoice( ctx.EffectiveChat.Id, fileID, &gotgbot.SendVoiceOpts{ ParseMode: HTML, ReplyMarkup: keyb, Caption: msg, MessageThreadId: ctx.EffectiveMessage.MessageThreadId, }, ) }, db.VIDEO: func(b *gotgbot.Bot, ctx *ext.Context, msg, fileID string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error) { return b.SendVideo( ctx.EffectiveChat.Id, fileID, &gotgbot.SendVideoOpts{ ParseMode: HTML, ReplyMarkup: keyb, Caption: msg, MessageThreadId: ctx.EffectiveMessage.MessageThreadId, }, ) }, db.VideoNote: func(b *gotgbot.Bot, ctx *ext.Context, msg, fileID string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error) { return b.SendVideoNote( ctx.EffectiveChat.Id, fileID, &gotgbot.SendVideoNoteOpts{ ReplyMarkup: keyb, MessageThreadId: ctx.EffectiveMessage.MessageThreadId, }, ) }, }
GreetingsEnumFuncMap FIXME: when using /welcome command in private with connection, the string of welcome is sent to connected chat instead of pm GreetingsEnumFuncMap A rather very complicated GreetingsEnumFuncMap Variable made by me to send filters in an appropriate way
var NotesEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, noteData *db.ChatNotes, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, webPreview, isProtected bool, noFormat, noNotif bool) (*gotgbot.Message, error){ db.TEXT: func(b *gotgbot.Bot, ctx *ext.Context, noteData *db.ChatNotes, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, webPreview, isProtected bool, noFormat, noNotif bool) (*gotgbot.Message, error) { formatMode := HTML if noFormat { formatMode = None } return b.SendMessage(ctx.Update.Message.Chat.Id, noteData.NoteContent, &gotgbot.SendMessageOpts{ ParseMode: formatMode, DisableWebPagePreview: !webPreview, ReplyMarkup: keyb, ReplyToMessageId: replyMsgId, AllowSendingWithoutReply: true, ProtectContent: isProtected, DisableNotification: noNotif, MessageThreadId: ctx.Update.Message.MessageThreadId, }, ) }, db.STICKER: func(b *gotgbot.Bot, ctx *ext.Context, noteData *db.ChatNotes, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, _, isProtected bool, noFormat, noNotif bool) (*gotgbot.Message, error) { return b.SendSticker(ctx.Update.Message.Chat.Id, noteData.FileID, &gotgbot.SendStickerOpts{ ReplyToMessageId: replyMsgId, ReplyMarkup: keyb, AllowSendingWithoutReply: true, ProtectContent: isProtected, DisableNotification: noNotif, MessageThreadId: ctx.Update.Message.MessageThreadId, }, ) }, db.DOCUMENT: func(b *gotgbot.Bot, ctx *ext.Context, noteData *db.ChatNotes, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, _, isProtected bool, noFormat, noNotif bool) (*gotgbot.Message, error) { formatMode := HTML if noFormat { formatMode = None } return b.SendDocument(ctx.Update.Message.Chat.Id, noteData.FileID, &gotgbot.SendDocumentOpts{ ReplyToMessageId: replyMsgId, ParseMode: formatMode, ReplyMarkup: keyb, Caption: noteData.NoteContent, AllowSendingWithoutReply: true, ProtectContent: isProtected, DisableNotification: noNotif, MessageThreadId: ctx.Update.Message.MessageThreadId, }, ) }, db.PHOTO: func(b *gotgbot.Bot, ctx *ext.Context, noteData *db.ChatNotes, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, _, isProtected bool, noFormat, noNotif bool) (*gotgbot.Message, error) { formatMode := HTML if noFormat { formatMode = None } return b.SendPhoto(ctx.Update.Message.Chat.Id, noteData.FileID, &gotgbot.SendPhotoOpts{ ReplyToMessageId: replyMsgId, ParseMode: formatMode, ReplyMarkup: keyb, Caption: noteData.NoteContent, AllowSendingWithoutReply: true, ProtectContent: isProtected, DisableNotification: noNotif, MessageThreadId: ctx.Update.Message.MessageThreadId, }, ) }, db.AUDIO: func(b *gotgbot.Bot, ctx *ext.Context, noteData *db.ChatNotes, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, _, isProtected bool, noFormat, noNotif bool) (*gotgbot.Message, error) { formatMode := HTML if noFormat { formatMode = None } return b.SendAudio(ctx.Update.Message.Chat.Id, noteData.FileID, &gotgbot.SendAudioOpts{ ReplyToMessageId: replyMsgId, ParseMode: formatMode, ReplyMarkup: keyb, Caption: noteData.NoteContent, AllowSendingWithoutReply: true, ProtectContent: isProtected, DisableNotification: noNotif, MessageThreadId: ctx.Update.Message.MessageThreadId, }, ) }, db.VOICE: func(b *gotgbot.Bot, ctx *ext.Context, noteData *db.ChatNotes, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, _, isProtected bool, noFormat, noNotif bool) (*gotgbot.Message, error) { formatMode := HTML if noFormat { formatMode = None } return b.SendVoice(ctx.Update.Message.Chat.Id, noteData.FileID, &gotgbot.SendVoiceOpts{ ReplyToMessageId: replyMsgId, ParseMode: formatMode, ReplyMarkup: keyb, Caption: noteData.NoteContent, AllowSendingWithoutReply: true, ProtectContent: isProtected, DisableNotification: noNotif, MessageThreadId: ctx.Update.Message.MessageThreadId, }, ) }, db.VIDEO: func(b *gotgbot.Bot, ctx *ext.Context, noteData *db.ChatNotes, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, _, isProtected bool, noFormat, noNotif bool) (*gotgbot.Message, error) { formatMode := HTML if noFormat { formatMode = None } return b.SendVideo(ctx.Update.Message.Chat.Id, noteData.FileID, &gotgbot.SendVideoOpts{ ReplyToMessageId: replyMsgId, ParseMode: formatMode, ReplyMarkup: keyb, Caption: noteData.NoteContent, AllowSendingWithoutReply: true, ProtectContent: isProtected, DisableNotification: noNotif, MessageThreadId: ctx.Update.Message.MessageThreadId, }, ) }, db.VideoNote: func(b *gotgbot.Bot, ctx *ext.Context, noteData *db.ChatNotes, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, _, isProtected bool, noFormat, noNotif bool) (*gotgbot.Message, error) { return b.SendVideoNote(ctx.Update.Message.Chat.Id, noteData.FileID, &gotgbot.SendVideoNoteOpts{ ReplyToMessageId: replyMsgId, ReplyMarkup: keyb, AllowSendingWithoutReply: true, ProtectContent: isProtected, DisableNotification: noNotif, MessageThreadId: ctx.Update.Message.MessageThreadId, }, ) }, }
NotesEnumFuncMap TODO: make a new function to merge all EnumFuncMap functions NotesEnumFuncMap A rather very complicated NotesEnumFuncMap Variable made by me to send filters in an appropriate way
Functions ¶
func BuildKeyboard ¶
BuildKeyboard is used to build a keyboard from a list of buttons provided by the database.
func ChunkKeyboardSlices ¶
func ChunkKeyboardSlices(slice []gotgbot.InlineKeyboardButton, chunkSize int) (chunks [][]gotgbot.InlineKeyboardButton)
ChunkKeyboardSlices function used in making the help menu keyboard
func ConvertButtonV2ToDbButton ¶
ConvertButtonV2ToDbButton is used to convert []tgmd2html.ButtonV2 to []db.Button
func ExtractAdminUpdateStatusChange ¶
func ExtractAdminUpdateStatusChange(u *gotgbot.ChatMemberUpdated) bool
ExtractAdminUpdateStatusChange Takes a ChatMemberUpdated instance and extracts whether the 'old_chat_member' was a member or admin of the chat and whether the 'new_chat_member' is a admin of the chat. Returns false, if the status didn't change.
func ExtractJoinLeftStatusChange ¶
ExtractJoinLeftStatusChange Takes a ChatMemberUpdated instance and extracts whether the 'old_chat_member' was a member of the chat and whether the 'new_chat_member' is a member of the chat. Returns false, if the status didn't change.
func FormattingReplacer ¶
func FormattingReplacer(b *gotgbot.Bot, chat *gotgbot.Chat, user *gotgbot.User, oldMsg string, buttons []db.Button) (res string, btns []db.Button)
FormattingReplacer replaces the formatting in a message.
func GetFullName ¶
GetFullName returns the full name of a user.
func GetLangFormat ¶
GetLangFormat returns the language name and flag.
func GetMessageLinkFromMessageId ¶
GetMessageLinkFromMessageId Gets the message link via chat Id and message Id maybe replace in future by msg.GetLink()
func GetNoteAndFilterType ¶
func GetNoteAndFilterType(msg *gotgbot.Message, isFilter bool) (keyWord, fileid, text string, dataType int, buttons []db.Button, pvtOnly, grpOnly, adminOnly, webPrev, isProtected, noNotif bool, errorMsg string)
GetNoteAndFilterType is a helper function to get the note and filter type from a *gotgbot.Message object.
func GetWelcomeType ¶
func GetWelcomeType(msg *gotgbot.Message, greetingType string) (text string, dataType int, fileid string, buttons []db.Button, errorMsg string)
GetWelcomeType is a helper function to get the welcome type from a *gotgbot.Message object.
func InitButtons ¶
func InitButtons(b *gotgbot.Bot, chatId, userId int64) gotgbot.InlineKeyboardMarkup
InitButtons initializes the buttons for the connection menu.
func InlineKeyboardMarkupToTgmd2htmlButtonV2 ¶
func InlineKeyboardMarkupToTgmd2htmlButtonV2(replyMarkup *gotgbot.InlineKeyboardMarkup) (btns []tgmd2html.ButtonV2)
InlineKeyboardMarkupToTgmd2htmlButtonV2 this func is used to convert gotgbot.InlineKeyboardarkup to []tgmd2html.ButtonV2
func IsUserConnected ¶
func IsUserConnected(b *gotgbot.Bot, ctx *ext.Context, chatAdmin, botAdmin bool) (chat *gotgbot.Chat)
IsUserConnected checks if a user is connected to a chat.
func MakeLanguageKeyboard ¶
func MakeLanguageKeyboard() [][]gotgbot.InlineKeyboardButton
MakeLanguageKeyboard makes a keyboard with all the languages in it.
func MentionHtml ¶
MentionHtml returns a mention in html format.
func MentionUrl ¶
MentionUrl returns a mention in html format.
func PasteToNekoBin ¶
PasteToNekoBin CreateTelegraphPost function used to create a Telegraph Page/Post with provide text We can use '<br>' inline text to split the messages into different paragraphs
func ReverseHTML2MD ¶
ReverseHTML2MD function to convert html formatted raw string to markdown to get noformat string
func RevertButtons ¶
RevertButtons is used to convert []db.Button to string
func SendFilter ¶
func SendFilter(b *gotgbot.Bot, ctx *ext.Context, filterData *db.ChatFilters, replyMsgId int64) (*gotgbot.Message, error)
SendFilter Simple function used to send a filter with help from EnumFuncMap, this just organises data for it
func SendNote ¶
func SendNote(b *gotgbot.Bot, chat *gotgbot.Chat, ctx *ext.Context, noteData *db.ChatNotes, replyMsgId int64) (*gotgbot.Message, error)
SendNote Simple function used to send a note with help from EnumFuncMap, this just organises data for it and returns the message
func Shtml ¶
func Shtml() *gotgbot.SendMessageOpts
Shtml is a shortcut for SendMessageOpts with HTML parse mode.
func Smarkdown ¶
func Smarkdown() *gotgbot.SendMessageOpts
Smarkdown is a shortcut for SendMessageOpts with Markdown parse mode.
func SplitMessage ¶
SplitMessage splits a message into multiple messages if it is too long.
Types ¶
This section is empty.