Documentation
¶
Index ¶
- Variables
- func CreateMultiPartReq(ctx context.Context, method, url string, fields map[string]string, ...) (*http.Request, error)
- func CreateReder(botob any) io.ReadCloser
- func Createkeyboard(keyboard *InlineKeyboardMarkup) ([]byte, error)
- func TemplateInit(sender BotAPI, sudoadminID int64, logger *zap.Logger, templates []*MgItem) error
- type BotAPI
- type BotReader
- type Botapi
- func (b *Botapi) AnswereCallbackCtx(ctx context.Context, Callbackanswere *Callbackanswere) error
- func (b *Botapi) AnswereInlineQuary(ctx context.Context) error
- func (b *Botapi) CreateFullUrl(endpoint string) string
- func (b *Botapi) DeleteMsg(ctx context.Context, msgid int64, chatid int64) error
- func (b *Botapi) GetFile(filed_id string) (io.ReadCloser, error)
- func (b *Botapi) GetMgStore() *MessageStore
- func (b *Botapi) GetchatmemberCtx(ctx context.Context, Userid int64, Chatid int64) (*tgbotapi.ChatMember, bool, error)
- func (b *Botapi) Makerequest(reqctx context.Context, method, endpoint string, body io.ReadCloser) (*tgbotapi.APIResponse, error)
- func (b *Botapi) Send(msg *Msgcommon) (*tgbotapi.Message, error)
- func (b *Botapi) SendContext(ctx context.Context, msg *Msgcommon) (*tgbotapi.Message, error)
- func (b *Botapi) SendError(err error, UserID int64)
- func (b *Botapi) SendRawReq(req *http.Request) (*tgbotapi.APIResponse, error)
- func (b *Botapi) SetWebhook(webhookurl, secret, ip_addr string, allo_updates []string) error
- type Buttons
- func (b *Buttons) AddBack(newline bool)
- func (b *Buttons) AddBtcommon(btn string)
- func (b *Buttons) AddClose(newline bool)
- func (b *Buttons) AddCloseBack()
- func (b *Buttons) AddUrlbutton(name, url string)
- func (b *Buttons) Addbutton(btnname, data, url string)
- func (b *Buttons) Addcancle()
- func (b *Buttons) Getkeyboard() Keyboard
- func (b *Buttons) ID() int64
- func (b *Buttons) Marshell() (json.RawMessage, error)
- func (b *Buttons) PassButtons(count int16)
- func (b *Buttons) Passline()
- func (b *Buttons) Reset(btmatrix []int16)
- type Callbackanswere
- type Callbackdata
- type CommonUsage
- type CommonUser
- type Filepart
- type Filesend
- type Htmlstring
- type Infocontext
- type InlineKeyboardButton
- type InlineKeyboardMarkup
- type InputMedia
- type Keyboard
- type Meadiacommon
- type Message
- type MessageStore
- type MgItem
- type Msgcommon
- type Msgsession
- func (m *Msgsession) Addreply(id int)
- func (m *Msgsession) AddreplyNoDelete(id int)
- func (m *Msgsession) Callbackanswere(quoaryid, text string, alert bool) error
- func (m *Msgsession) CopyMessageRawTo(to, mgid, fromchat int64) error
- func (m *Msgsession) CopyMessageTo(to int64, mgid int64) error
- func (m *Msgsession) DeleteAllMsg() error
- func (m *Msgsession) DeleteLast()
- func (m *Msgsession) DeleteReplys() error
- func (m *Msgsession) Edit(msg any, buttons *Buttons, name string) (*tgbotapi.Message, error)
- func (m *Msgsession) EditNewcontext(ctx context.Context, msg any, buttons *Buttons, name string) (*tgbotapi.Message, error)
- func (m *Msgsession) EditText(msg string, buttons *Buttons) (*tgbotapi.Message, error)
- func (m *Msgsession) ForwardMgTo(to int64, mgid, fromchat int64) error
- func (m *Msgsession) RemoveBtns() error
- func (m *Msgsession) SendAlert(msg any, buttons *Buttons) (*tgbotapi.Message, error)
- func (m *Msgsession) SendExtranal(msg any, buttons *Buttons, name string, nodel bool) (*tgbotapi.Message, error)
- func (m *Msgsession) SendNew(msg any, buttons *Buttons, name string) (*tgbotapi.Message, error)
- func (m *Msgsession) SendTmpl(name string, obj any, btns *Buttons) (*tgbotapi.Message, error)
- func (m *Msgsession) SetNewcontext(ctx context.Context)
- func (m *Msgsession) SetPrimeLast()
- type UpMessage
- type UsageAll
Constants ¶
This section is empty.
Variables ¶
var Testtemplts map[string]map[string]MgItem = map[string]map[string]MgItem{ "welcome": {"sin": { Msgtmpl: "hello", ParseMode: "HTML", }}, "configusage": {"sin": { Msgtmpl: "hello", ParseMode: "HTML", }}, constbot.TmpConfigInfo: { "sin": {ParseMode: "HTML", Msgtmpl: "සින්හලැන්"}, "en": { ParseMode: "HTML", Msgtmpl: ` <b>{{.Name}} </b> You have tatal {{.TotalQuota}} Config Info Config Name := {{.ConfigName}} Config Type := {{.ConfigType}} Config UUID := {{.ConfigUUID}} ConfigUpload := {{.ConfigUpload }} ConfigDownload := {{.ConfigDownload}} ConfigUploadtd := {{.ConfigUploadtd}} ConfigDownloadtd := {{.ConfigDownloadtd}} ConfigUsage := {{.ConfigUsage}} ConfigUsagetd := {{.ConfigUsagetd}} InName := {{.InName}} InType := {{.InType}} InPort := {{.InPort}} InAddr := {{.InAddr}} InInfo := {{.InInfo}} TranstPortType := {{.TranstPortType}} TlsEnabled := {{.TlsEnabled}} TotalQuota := {{.TotalQuota}} OutName = {{.OutName}} OutType = {{.OutType}} OutInfo = {{.OutInfo}} Days to Reset Usage = {{.ResetDays}} `, }, }, constbot.TmpConQuota: { "en": { Msgtmpl: "Send New quota for config {{.AvblQuota}}", ParseMode: "HTML", }, }, constbot.TmpCrAvblQuota: { "en": { Msgtmpl: "You have available quota {{.Quota}}", ParseMode: "HTML", }, }, constbot.TmpCrAlreadyHave: { "en": { Msgtmpl: "You already have {{.Count}}", ParseMode: "HTML", }, }, constbot.TmpStTotal: { "en": { Msgtmpl: `Your usage ✅ tddwn {{.TDownload}} tdup {{.TUpload}} totalUp {{.MUpload}} totaldown {{.MDownload}} Alltime {{.Alltime}} Month {{.MonthAll}} If you want config-specific usage, click the buttons below.`, ParseMode: "HTML", }, }, constbot.TmpStcallback: { "en": { Msgtmpl: "Your usage tddwn {{.TDownload}} tdup {{.TUpload}} totalUp {{.MUpload}} totaldown {{.MDownload}}", }, }, constbot.TmpcapQuota: { "en": { Msgtmpl: "you'r cap will end {{.EndDate}} ", ParseMode: "HTML", }, }, constbot.TmpcapWarn: { "en": { Msgtmpl: ` you have total {{.Leftquota}} which can be capped this cap automatically reset after 30 days and you left quota after capping will shared amoung all user also you can't undo this cap you have to wait, if the user quota goes down than your cap also your connection will offline `, }, }, constbot.Tmpcapreply: { "en": { Msgtmpl: ` Good now send me quota you need to cap {{.LeftQuota}} `, }, }, constbot.TmpGifSend: { "en": { Msgtmpl: "send how much do you need to send you have {{.LeftQuota}}", }, }, constbot.TmpChatmemLeft: { "en": { Msgtmpl: "Good Bye If you changed your mind feel free to rejoin {{.Name}} ", }, }, constbot.TmpGroupWelcome: { "en": { Msgtmpl: "Hello How are welcome to group {{.Name}}", }, }, constbot.TmpWelcomeInbox: { "en": { Msgtmpl: "Welcome Message Template user who did not started bot yet joined ", }, }, constbot.TmpGrpComeback: { "en": { Msgtmpl: "Hello welcome back to our group You are still not in our channel if you want to use again service please rejoin channel ", }, }, constbot.TmpHelpHome: { "en": { Msgtmpl: "Hello {{.Name}} Help page home", }, }, constbot.TmpAbout: { "en": { Msgtmpl: "Hello {{.Name}} About page", }, }, constbot.TmpregularVerified: { "en": { Includemed: true, Mediatype: "photo", MediaId: "AgACAgUAAxkBAAEvY5dnN5SVlrEmRFUSDBm1PWmfJUBrtwACF8IxG-qvuVVy0oe6c5lPTAEAAwIAA20AAzYE", Msgtmpl: "Hello {{.Name}} Verified user started all time - {{.Alltime}}, month usage {{.MUsage}} ", }, }, constbot.TmpConfiConfigure: { "en": { Includemed: true, Mediatype: "photo", MediaId: "AgACAgUAAxkBAAEvY5dnN5SVlrEmRFUSDBm1PWmfJUBrtwACF8IxG-qvuVVy0oe6c5lPTAEAAwIAA20AAzYE", Msgtmpl: "Hello Verified user started all time - , month usage ", ContinueMed: false, }, }, constbot.TmpHelpInfoPage + "1": { "en": { Msgtmpl: "Hello {{.Name}} hello this is info page 1 ", }, }, constbot.TmpHelpInfoPage + "2": { "en": { Includemed: true, Mediatype: "photo", MediaId: "AgACAgUAAxkBAAEvY5dnN5SVlrEmRFUSDBm1PWmfJUBrtwACF8IxG-qvuVVy0oe6c5lPTAEAAwIAA20AAzYE", Msgtmpl: "Hello {{.Name}} this is help info page 2", ContinueMed: false, }, }, constbot.TmpHelpInfoPage + "3": { "en": { Includemed: true, Mediatype: "photo", MediaId: "AgACAgUAAxkBAAEvZapnOFjKbTYqbIAgTIy0xf-VZQQ0PwACUcAxG8dwyVV7OMp6tw3cUwEAAwIAA3MAAzYE", Msgtmpl: "Hello {{.Name}} this is help info page 3", ContinueMed: true, }, }, constbot.TmpHelpInfoPage + "4": { "en": { Msgtmpl: "Hello {{.Name}} this is help info page 4 ", }, }, constbot.TmpHelpCmPage + "1": { "en": { Msgtmpl: "Hello {{.Name}} hello this is command page 1 ", }, }, constbot.TmpHelpCmPage + "2": { "en": { Msgtmpl: "Hello {{.Name}} this is help command page 2 ", }, }, constbot.TmpHelpCmPage + "3": { "en": { Msgtmpl: "Hello {{.Name}} this is help command page 3 ", }, }, constbot.TmpRefHome: { "en": { Msgtmpl: "Hello {{.Name}} You have {{.Refred}} users, and {{.Verified}} verified user you should have verified user to claim the gift, ( verified user = use who is in both group and channel) ", }, }, constbot.TmpRefshare: { "en": { Msgtmpl: "Hello Everyone I am {{.Name}} You can Join with {{.Botlink}} ", Includemed: true, Mediatype: "photo", MediaId: "AgACAgUAAxkBAAEvZapnOFjKbTYqbIAgTIy0xf-VZQQ0PwACUcAxG8dwyVV7OMp6tw3cUwEAAwIAA3MAAzYE", }, }, constbot.TmpUserInfo: { "en": { Msgtmpl: ` Name {{.Name}} Username = @{{.Username}} TgId = {{.TgId}} Dedicated {{.Dedicated}} TQuota {{.TQuota}} LeftQuota {{.LeftQuota}} ConfCount {{.ConfCount}} TUsage {{.TUsage}} GiftQuota {{.GiftQuota}} Joined {{.Joined}} CapEndin {{.CapEndin}} Disendin {{.Disendin}} UsageResetIn{{.UsageResetIn}} Iscapped {{.Iscapped}} Isgifted {{.Isgifted}} Isdisuser {{.Isdisuser}} IsMonthLimited {{.IsMonthLimited}} JoinedPlace {{.JoinedPlace}} {{if .Iscapped}} CapEndin = {{.CapEndin}} {{end}} {{if .Isgifted}} GiftEndIn = {{.GiftEndIn}} {{end}} `, }, }, constbot.TmpDisGroup: { "en": { Msgtmpl: "Hello Everyone user{{.Name}} is distributed his quota everyone clap hiom and thanks he dedicated {{.Disquota}}, රටක් දියුනු වෙන්න මේ වගෙ එව්න් තමා ඕන ", Includemed: true, Mediatype: "photo", MediaId: "AgACAgUAAxkBAAEvZapnOFjKbTYqbIAgTIy0xf-VZQQ0PwACUcAxG8dwyVV7OMp6tw3cUwEAAwIAA3MAAzYE", }, }, constbot.TmpCrInInfo: { "en": { Msgtmpl: `selected inbound info is here if you want excatly this seeting for your config conform also you can change the inbound later InName {{.InName}} InType {{.InType}} InPort {{.InPort}} InAddr {{.InAddr}} InInfo {{.InInfo}} TranstPortType {{.TranstPortType}} TlsEnabled {{.TlsEnabled}} Domain {{.Domain}} PublicIp {{.PublicIp}} `, }, }, constbot.TmpCrSendUID: { "en": { Msgtmpl: ` this is tempory config structure we will provide good way to generate configs as you need till then use this UUID {{.UUID}} Domain {{.Domain}} Transport {{.Transport}} ConfigName {{.ConfigName}} TlsEnabled {{.TlsEnabled}} Port {{.Port}} `, }, }, constbot.TmpInchange: { "en": { Msgtmpl: ` Info about inbound that you are goung to change InName {{.InName}} InType {{.InType}} InPort {{.InPort}} InAddr {{.InAddr}} InInfo {{.InInfo}} TranstPortType {{.TranstPortType}} TlsEnabled {{.TlsEnabled}} Domain {{.Domain}} PublicIp {{.PublicIp}} `, }, }, constbot.TmpOutchange: { "en": { Msgtmpl: ` Selected Outbound info OutName {{.OutName}} OutType {{.OutType}} OutInfo {{.OutInfo}} Latency {{.Latency}}ms `, }, }, }
Functions ¶
func CreateMultiPartReq ¶
func CreateReder ¶
func CreateReder(botob any) io.ReadCloser
func Createkeyboard ¶
func Createkeyboard(keyboard *InlineKeyboardMarkup) ([]byte, error)
Types ¶
type BotAPI ¶
type BotAPI interface {
Makerequest(ctx context.Context, method, endpoint string, body io.ReadCloser) (*tgbotapi.APIResponse, error)
SendRawReq(req *http.Request) (*tgbotapi.APIResponse, error)
SendContext(ctx context.Context, msg *Msgcommon) (*tgbotapi.Message, error)
AnswereCallbackCtx(ctx context.Context, Callbackanswere *Callbackanswere) error
GetchatmemberCtx(ctx context.Context, Userid int64, Chatid int64) (*tgbotapi.ChatMember, bool, error)
//Createkeyboard(keyboard *InlineKeyboardMarkup) ([]byte,error)
Send(msg *Msgcommon) (*tgbotapi.Message, error)
SendError(error, int64)
DeleteMsg(ctx context.Context, msgid int64, chatid int64) error
GetMgStore() *MessageStore
SetWebhook(webhookurl, secret, ip_addr string, allowd_ob []string) error
CreateFullUrl(endpoint string) string
GetFile(file_Id string) (io.ReadCloser, error)
}
type Botapi ¶
func NewBot ¶
func NewBot(ctx context.Context, token, mainurl string, mgstore *MessageStore) *Botapi
func (*Botapi) AnswereCallbackCtx ¶
func (b *Botapi) AnswereCallbackCtx(ctx context.Context, Callbackanswere *Callbackanswere) error
func (*Botapi) CreateFullUrl ¶
func (*Botapi) GetMgStore ¶
func (b *Botapi) GetMgStore() *MessageStore
func (*Botapi) GetchatmemberCtx ¶
func (*Botapi) Makerequest ¶
func (b *Botapi) Makerequest(reqctx context.Context, method, endpoint string, body io.ReadCloser) (*tgbotapi.APIResponse, error)
Endpoint should be without slash "/"
func (*Botapi) SendContext ¶
func (*Botapi) SendRawReq ¶
type Buttons ¶
type Buttons struct {
InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
// contains filtered or unexported fields
}
func NewButtons ¶
Create button Schema Examle if you give []int16{2, 1, 3,}, when you call Addbuttons button will add to this ass the map Ex :-
btn btn, btn
btn btn btn
func (*Buttons) AddBtcommon ¶
func (*Buttons) AddCloseBack ¶
func (b *Buttons) AddCloseBack()
Should Called After adding allbuttons
func (*Buttons) AddUrlbutton ¶
func (*Buttons) Getkeyboard ¶
func (*Buttons) PassButtons ¶
type Callbackanswere ¶
type Callbackanswere struct {
Callback_query_id string `json:"callback_query_id"`
Show_alert bool `json:"show_alert,omitempty"`
Cache_time int16 `json:"cache_time,omitempty"`
Text string `json:"text,omitempty"`
// contains filtered or unexported fields
}
func (*Callbackanswere) Close ¶
func (m *Callbackanswere) Close() error
type Callbackdata ¶
func (*Callbackdata) FillV2 ¶
func (c *Callbackdata) FillV2(data string) error
func (*Callbackdata) StringV2 ¶
func (c *Callbackdata) StringV2() string
type CommonUsage ¶
type CommonUser ¶
common input types All of type below are for template render
type Htmlstring ¶
type Htmlstring string
type Infocontext ¶
type InlineKeyboardButton ¶
type InlineKeyboardButton struct {
Text string `json:"text,omitempty"`
CallbackData string `json:"callback_data,omitempty"` // For button actions
URL string `json:"url,omitempty"` // For opening a URL
}
InlineKeyboardButton represents a button in the inline keyboard
type InlineKeyboardMarkup ¶
type InlineKeyboardMarkup struct {
InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
}
type InputMedia ¶
type InputMedia struct {
Type string `json:"type"`
Media string `json:"media"`
Caption string `json:"caption,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
}
use only for editmeadia
func (*InputMedia) Marshal ¶
func (i *InputMedia) Marshal() json.RawMessage
type Keyboard ¶
type Keyboard struct {
Inline_keyboard [][]InlineKeyboardButton `json:"inline_keyboard,omitempty"`
}
type Meadiacommon ¶
type Meadiacommon struct {
//sending newly media
Photo any `json:"photo,omitempty"`
Video any `json:"video,omitempty"`
Caption string `json:"caption,omitempty"`
Has_spoiler bool `json:"has_spoiler,omitempty"`
//this field for editing meadia
Media *InputMedia `json:"media,omitempty"`
}
type Message ¶
type Message struct {
Msg string
ParseMode string
Includemed bool
MedType string
MediaId string
ContinueMed bool
Disabled bool
SkipText bool
Continue_Skip_Text bool
SuperContinue bool
MeadiaSkip bool
}
io.Writer for excution
type MessageStore ¶
func NewMessageStore ¶
func NewMessageStore(path string) (*MessageStore, error)
func (*MessageStore) GetMessage ¶
func (m *MessageStore) GetMessage(name, lang string, obj any) (*Message, error)
func (*MessageStore) GetPath ¶
func (m *MessageStore) GetPath() string
func (*MessageStore) MsgWithouerro ¶
func (m *MessageStore) MsgWithouerro(name, lang string, obj any) string
type MgItem ¶
type MgItem struct {
Msgtmpl string `json:"msg_template" yaml:"msg_template"`
ParseMode string `json:"parse_mode" yaml:"parse_mode" `
Includemed bool `json:"include_media" yaml:"include_media"`
Mediatype string `json:"media_type" yaml:"media_type"`
MediaId string `json:"media_id" yaml:"media_id" `
ContinueMed bool `json:"continue_media" yaml:"continue_media"`
Disabled bool `json:"disabled" yaml:"disabled"`
SkipText bool `json:"skip_text" yaml:"skip_text"`
Continue_Skip_Text bool `json:"contin_skip_text" yaml:"contin_skip_text"`
SuperContinue bool `json:"supercontinue" yaml:"supercontinue"`
AltMediaUrl string `json:"alt_med_url" yaml:"alt_med_url"`
AltMediaPath string `json:"alt_med_path" yaml:"alt_med_path"`
MeadiaSkip bool `json:"media_skip" yaml:"media_skip"`
// contains filtered or unexported fields
}
func (*MgItem) ChangeField ¶
type Msgcommon ¶
type Msgcommon struct {
*Infocontext
Message_thread_id int64 `json:"message_thread_id,omitempty"`
Text string `json:"text,omitempty"`
Parse_mode string `json:"parse_mode,omitempty"`
Reply_markup Keyboard `json:"reply_markup,omitempty"`
Message_id int64 `json:"message_id,omitempty"`
//meadia
*Meadiacommon
Endpoint string `json:"-"`
// contains filtered or unexported fields
}
func (*Msgcommon) SetMedType ¶
type Msgsession ¶
type Msgsession struct {
ChatID int64
MessageID int
Lasscallbackid int64
Prime int64 //Deorecated
// contains filtered or unexported fields
}
This object Is not concurrent safe use it only in one go routine
func NewMsgsession ¶
func (*Msgsession) Addreply ¶
func (m *Msgsession) Addreply(id int)
func (*Msgsession) AddreplyNoDelete ¶
func (m *Msgsession) AddreplyNoDelete(id int)
After adding reply, current mg will not delete and resend
func (*Msgsession) Callbackanswere ¶
func (m *Msgsession) Callbackanswere(quoaryid, text string, alert bool) error
func (*Msgsession) CopyMessageRawTo ¶
func (m *Msgsession) CopyMessageRawTo(to, mgid, fromchat int64) error
func (*Msgsession) CopyMessageTo ¶
func (m *Msgsession) CopyMessageTo(to int64, mgid int64) error
func (*Msgsession) DeleteAllMsg ¶
func (m *Msgsession) DeleteAllMsg() error
func (*Msgsession) DeleteLast ¶
func (m *Msgsession) DeleteLast()
func (*Msgsession) DeleteReplys ¶
func (m *Msgsession) DeleteReplys() error
func (*Msgsession) Edit ¶
Many types supported by this method msg parameter can be Upmessage, struct with template name, or string
func (*Msgsession) EditNewcontext ¶
func (*Msgsession) ForwardMgTo ¶
func (m *Msgsession) ForwardMgTo(to int64, mgid, fromchat int64) error
func (*Msgsession) RemoveBtns ¶
func (m *Msgsession) RemoveBtns() error
remove all btns from last sent msg this functiuon does not gurntee anything
func (*Msgsession) SendAlert ¶
Will send a compleatly new msg not relvent edititn msgs will automatically remove with delete all
func (*Msgsession) SendExtranal ¶
func (*Msgsession) SetNewcontext ¶
func (m *Msgsession) SetNewcontext(ctx context.Context)
func (*Msgsession) SetPrimeLast ¶
func (m *Msgsession) SetPrimeLast()