telepher

package module
v0.0.0-...-a28f0ed Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: GPL-3.0 Imports: 18 Imported by: 0

README

telepher

Support Chat Off-topic

Features
Usage
package main

import (
    tl "github.com/goTelegramBot/telepher"
       "github.com/goTelegramBot/telepher/types"
)
  

func main() {
    
           b,err := tl.NewBot(os.Getenv("TOKEN"),nil)
    
           if err != nil{
                log.Println(err)
                return
           }

           b.Command("start",start)
           b.Start()
}
func start(bot tl.Bot,message *types.Message) {
            text := "Hi there!"
    
            markup := tl.InlineKeyboardMarkup()
            
            but1 := types.InlineKeyboardButton{Text:"Channel",Url: "https://t.me/theostrich"}
            but2 := types.InlineKeyboardButton{Text:"Support",Url: "https://t.me/ostrichdiscussion"}
            
            row1 := markup.Row(but1,but2)
            keyboard := markup.Parse(row1)
     
            bot.SendMessage(message.Chat.Id, text,&tl.Options{ReplyMarkup:&keyboard,ParseMode:"Markdown"})
}
     

For additional bot examples check examples repository.

          ,_---~~~~~----._
   _,,_,*^____      _____``*g*\"*,
  / __/ /'     ^.  /      \ ^@q   f
 [  @f | @))    |  | @))   l  0 _/
  \`/   \~____ / __ \_____/    \
   |           _l__l_           I
   }          [______]           I
   ]            | | |            |
   ]             ~ ~             |
   |                            |
    |                           |
    ```

Documentation

Index

Constants

View Source
const (
	DefaultBaseURL     = "https://api.telegram.org/bot"
	DefaultBaseFileURL = "https://api.telegram.org/file/bot"
	DefaultParseMode   = ""
	DefaultCheckBool   = true
)
View Source
const (
	Message            = "message"
	EditedMessage      = "edited_message"
	ChannelPost        = "channel_post"
	EditedChannelPost  = "edited_channel_post"
	InlineQuery        = "inline_query"
	ChosenInlineResult = "chosen_inline_result"
	CallbackQuery      = "callback_query"
	ShippingQuery      = "shipping_query"
	PreCheckoutQuery   = "pre_checkout_query"
	Poll               = "poll"
	PollAnswer         = "inline_query"
	MyChatMember       = "my_chat_member"
	ChatMember         = "chat_member"
	Text               = "text"
)

events

View Source
const DefaultHandlerGroup = 0

Variables

View Source
var DefaultClient = &http.Client{
	Timeout: time.Second * 10,
}
View Source
var PARSE_MODES = []string{"markdownv2", "html", "markdown", ""}

Functions

This section is empty.

Types

type Bot

type Bot struct {
	Token       string
	BaseURL     string
	BaseFileURL string
	Handlers    map[int][]Handler
	Commands    map[string][]Commands
	Client      *http.Client
	ParseMode   string
	Update      chan types.Update
	Self        *types.User
}

func NewBot

func NewBot(token string, settings *Settings) (*Bot, error)

func (Bot) AddStickerToSet

func (telepher Bot) AddStickerToSet(user_id int, name string, emojis string, png_sticker types.InputFile, option interface{}) (*types.Message, error)

func (Bot) AnswerCallbackQuery

func (telepher Bot) AnswerCallbackQuery(callback_query_id string) (bool, error)

func (Bot) CanJoinGroups

func (telepher Bot) CanJoinGroups() bool

func (Bot) CanReadAllGroupMessages

func (telepher Bot) CanReadAllGroupMessages() bool

func (Bot) Command

func (telepher Bot) Command(trigger string, commandHandler func(Bot, *types.Message))

func (Bot) CommandHandler

func (telepher Bot) CommandHandler(trigger string, msg *types.Message)

func (Bot) CopyMessage

func (telepher Bot) CopyMessage(chat_id int, from_chat_id int, message_id int, option interface{}) (*types.MessageId, error)
func (telepher Bot) CreateChatInviteLink(chat_id int, option interface{}) (*types.ChatInviteLink, error)

func (Bot) CreateNewStickerSet

func (telepher Bot) CreateNewStickerSet(user_id int, name string, title string, emojis string, png_sticker types.InputFile, option interface{}) (*types.Message, error)

func (Bot) DeleteChatPhoto

func (telepher Bot) DeleteChatPhoto(chat_id int) (bool, error)

func (Bot) DeleteChatStickerSet

func (telepher Bot) DeleteChatStickerSet(chat_id int) (bool, error)

func (Bot) DeleteMessage

func (telepher Bot) DeleteMessage(chat_id int, message_id int) (*types.Message, error)

func (Bot) DeleteStickerFromSet

func (telepher Bot) DeleteStickerFromSet(sticker string) (bool, error)
func (telepher Bot) EditChatInviteLink(chat_id int, invite_link string, option interface{}) (*types.ChatInviteLink, error)

func (Bot) EditMessageCaption

func (telepher Bot) EditMessageCaption() (*types.Message, error)

func (Bot) EditMessageLiveLocation

func (telepher Bot) EditMessageLiveLocation(latitude float64, longitude float64, option interface{}) (*types.Message, error)

func (Bot) EditMessageReplyMarkup

func (telepher Bot) EditMessageReplyMarkup() (*types.Message, error)

func (Bot) EditMessageText

func (telepher Bot) EditMessageText(text string) (*types.Message, error)
func (telepher Bot) ExportChatInviteLink(chat_id int) (string, error)

func (Bot) FirstName

func (telepher Bot) FirstName() string

func (Bot) ForwardMessage

func (telepher Bot) ForwardMessage(chat_id int, from_chat_id int, message_id int, option interface{}) (*types.Message, error)

func (Bot) GetChat

func (telepher Bot) GetChat(chat_id int) (*types.Chat, error)

func (Bot) GetChatAdministrators

func (telepher Bot) GetChatAdministrators(chat_id int) (*[]types.ChatMember, error)

func (Bot) GetChatMember

func (telepher Bot) GetChatMember(chat_id int, user_id int) (*types.ChatMember, error)

func (Bot) GetChatMembersCount

func (telepher Bot) GetChatMembersCount(chat_id int) (int, error)

func (Bot) GetFile

func (telepher Bot) GetFile(file_id string) (*types.File, error)

func (Bot) GetMe

func (telepher Bot) GetMe() (*types.User, error)

func (Bot) GetMyCommands

func (telepher Bot) GetMyCommands() ([]*types.BotCommand, error)

func (Bot) GetStickerSet

func (telepher Bot) GetStickerSet(name string) (*types.StickerSet, error)

func (Bot) GetUpdates

func (telepher Bot) GetUpdates(offset int, limit int) ([]types.Update, error)

func (Bot) GetUserProfilePhotos

func (telepher Bot) GetUserProfilePhotos(user_id int, option interface{}) (*types.UserProfilePhotos, error)

func (Bot) Hears

func (telepher Bot) Hears(trigger string, handler interface{}, handlerOptions *HandlerOptions)

func (Bot) ID

func (telepher Bot) ID() int

func (Bot) IsBot

func (telepher Bot) IsBot() bool

func (Bot) KickChatMember

func (telepher Bot) KickChatMember(chat_id int, user_id int, option interface{}) (bool, error)

func (Bot) LanguageCode

func (telepher Bot) LanguageCode() string

func (Bot) LastName

func (telepher Bot) LastName() string

func (Bot) LeaveChat

func (telepher Bot) LeaveChat(chat_id int) (bool, error)

func (*Bot) On

func (telepher *Bot) On(Type string, handler interface{}, handlerOptions *HandlerOptions)

func (Bot) PinChatMessage

func (telepher Bot) PinChatMessage(chat_id int, message_id int) (bool, error)

func (Bot) Poll

func (telepher Bot) Poll(ch chan types.Update)

func (Bot) PromoteChatMember

func (telepher Bot) PromoteChatMember(chat_id int, user_id int, option interface{}) (bool, error)

func (Bot) RestrictChatMember

func (telepher Bot) RestrictChatMember(chat_id int, user_id int, permissions *types.ChatPermissions, option interface{}) (bool, error)
func (telepher Bot) RevokeChatInviteLink(chat_id int, invite_link string) (*types.ChatInviteLink, error)

func (Bot) SendAnimation

func (telepher Bot) SendAnimation(chat_id int, animation types.InputFile, option interface{}) (*types.Message, error)

func (Bot) SendAudio

func (telepher Bot) SendAudio(chat_id int, photo types.InputFile, option interface{}) (*types.Message, error)

func (Bot) SendChatAction

func (telepher Bot) SendChatAction(chat_id int, action string) (*types.Message, error)

func (Bot) SendContact

func (telepher Bot) SendContact(chat_id int, phone_number string, first_name string, option interface{}) (*types.Message, error)

func (Bot) SendDice

func (telepher Bot) SendDice(chat_id int, option interface{}) (*types.Message, error)

func (Bot) SendDocument

func (telepher Bot) SendDocument(chat_id int, document types.InputFile, option interface{}) (*types.Message, error)

func (Bot) SendLocation

func (telepher Bot) SendLocation(chat_id int, latitude float64, longitude float64, option interface{}) (*types.Message, error)

func (Bot) SendMessage

func (telepher Bot) SendMessage(chat_id int, text string, option interface{}) (*types.Message, error)

func (Bot) SendPhoto

func (telepher Bot) SendPhoto(chat_id int, photo types.InputFile, option interface{}) (*types.Message, error)

func (Bot) SendPoll

func (telepher Bot) SendPoll(chat_id int, question string, poll_options []string, option interface{}) (*types.Message, error)

func (Bot) SendSticker

func (telepher Bot) SendSticker(chat_id int, video_note types.InputFile, option interface{}) (*types.Message, error)

func (Bot) SendVenue

func (telepher Bot) SendVenue(chat_id int, latitude float64, longitude float64, title string, address string, option interface{}) (*types.Message, error)

func (Bot) SendVideo

func (telepher Bot) SendVideo(chat_id int, video types.InputFile, option interface{}) (*types.Message, error)

func (Bot) SendVideoNote

func (telepher Bot) SendVideoNote(chat_id int, video_note types.InputFile, option interface{}) (*types.Message, error)

func (Bot) SendVoice

func (telepher Bot) SendVoice(chat_id int, voice types.InputFile, option interface{}) (*types.Message, error)

func (Bot) SetChatAdministratorCustomTitle

func (telepher Bot) SetChatAdministratorCustomTitle(chat_id int, user_id int, custom_title string) (bool, error)

func (Bot) SetChatDescription

func (telepher Bot) SetChatDescription(chat_id int, description string) (bool, error)

func (Bot) SetChatPermissions

func (telepher Bot) SetChatPermissions(chat_id int, permissions *types.ChatPermissions) (bool, error)

func (Bot) SetChatPhoto

func (telepher Bot) SetChatPhoto(chat_id int, photo types.InputFile) (*types.Message, error)

func (Bot) SetChatStickerSet

func (telepher Bot) SetChatStickerSet(chat_id int, stickersetname string) (bool, error)

func (Bot) SetChatTitle

func (telepher Bot) SetChatTitle(chat_id int, title string) (bool, error)

func (Bot) SetMyCommands

func (telepher Bot) SetMyCommands(command []types.BotCommand) (bool, error)

func (Bot) SetStickerPositionInSet

func (telepher Bot) SetStickerPositionInSet(sticker string, position int) (bool, error)

func (Bot) SetStickerSetThumb

func (telepher Bot) SetStickerSetThumb(name string, user_id int) (bool, error)

func (Bot) Start

func (telepher Bot) Start()

func (Bot) StopMessageLiveLocation

func (telepher Bot) StopMessageLiveLocation(option interface{}) (*types.Message, error)

func (Bot) StopPoll

func (telepher Bot) StopPoll(chat_id int, message_id int) (*types.Message, error)

func (Bot) SupportsInlineQueries

func (telepher Bot) SupportsInlineQueries() bool

func (Bot) UnbanChatMember

func (telepher Bot) UnbanChatMember(chat_id int, user_id int, option interface{}) (bool, error)

func (Bot) UnpinAllChatMessages

func (telepher Bot) UnpinAllChatMessages(chat_id int) (bool, error)

func (Bot) UnpinChatMessage

func (telepher Bot) UnpinChatMessage(chat_id int, message_id int) (bool, error)

func (Bot) UploadStickerFile

func (telepher Bot) UploadStickerFile(user_id int, png_sticker types.InputFile, option interface{}) (*types.Message, error)

func (Bot) UserName

func (telepher Bot) UserName() string

type Commands

type Commands struct {
	Command string

	HandlerOptions *HandlerOptions
	// contains filtered or unexported fields
}

type Handler

type Handler struct {
	Type    string
	Trigger *regexp.Regexp

	HandlerOptions *HandlerOptions
	// contains filtered or unexported fields
}

type HandlerOptions

type HandlerOptions struct {
	GroupID int
	// contains filtered or unexported fields
}

type InlineKeyboard

type InlineKeyboard struct {
}

func InlineKeyboardMarkup

func InlineKeyboardMarkup() *InlineKeyboard

func (InlineKeyboard) Parse

func (inlineKeyboard InlineKeyboard) Parse(buttons ...[]types.InlineKeyboardButton) types.ReplyMarkup

func (InlineKeyboard) Row

func (inline InlineKeyboard) Row(InlineButton ...types.InlineKeyboardButton) []types.InlineKeyboardButton

type KeyboardOptions

type KeyboardOptions struct {
	ResizeKeyboard  bool
	OneTimeKeyboard bool
	Selective       bool
}

type Options

type Options struct {
	ParseMode                string
	Entities                 []types.MessageEntity
	DisableWebPagePreview    bool
	DisableNotification      bool
	ReplyToMessageID         int
	AllowSendingWithoutReply bool
	ReplyMarkup              *types.ReplyMarkup
	Caption                  string
	CaptionEntities          []types.MessageEntity
	Params                   url.Values
}

type ParseMode

type ParseMode = string
const (
	Default    ParseMode = ""
	Markdown   ParseMode = "Markdown"
	MarkdownV2 ParseMode = "MarkdownV2"
	HTML       ParseMode = "HTML"
)

type ReplyKeyboard

type ReplyKeyboard struct {
	ResizeKeyboard  bool
	OneTimeKeyboard bool
	Selective       bool
}

func ReplyKeyboardMarkup

func ReplyKeyboardMarkup(keyboardOptions *KeyboardOptions) *ReplyKeyboard

func (ReplyKeyboard) Parse

func (replyKeyboard ReplyKeyboard) Parse(buttons ...[]types.KeyboardButton) types.ReplyMarkup

func (ReplyKeyboard) Row

func (keyboard ReplyKeyboard) Row(keyboardButton ...types.KeyboardButton) []types.KeyboardButton

type Settings

type Settings struct {
	BaseURL     string
	BaseFileURL string
	Client      *http.Client
	ParseMode   string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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