Help us shape the future of Go! Take the 2026 Go Developer Survey

telegram

package module
v0.0.0-...-955a999 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2017 License: MIT Imports: 7 Imported by: 1

README

Go Telegram

Package go-telegram allows interact with Telegram Bot API and parse web hooks from Telegram without getting bored.

Usage

To user go-telegram you should install it:

$ get github.com/kimrgrey/go-telegram

Now you can add go-telegram to the package list, create new client using your bot key and perform call of any method from this list. Notice, that method names have been converted to satisfy go coding style, so, for example, if you need to call getMe you should use client.GetMe(), like this:

package main

import (
        "fmt"
        "github.com/kimrgrey/go-telegram"
)
 
var client *telegram.Client = telegram.NewClient("YOUR_BOT_KEY")

func main() {
        me := client.GetMe()
        fmt.Println(me.UserName)
}

License

This code has been published under MIT License.

Documentation

Index

Constants

View Source
const BaseURL = "https://api.telegram.org"

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID        int    `json:"id"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	UserName  string `json:"username"`
}

type AccountResponse

type AccountResponse struct {
	Ok      bool    `json:"ok"`
	Account Account `json:"result"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(token string) *Client

func (*Client) Bot

func (cl *Client) Bot() string

func (*Client) Call

func (cl *Client) Call(method string, params url.Values, v interface{})

func (*Client) GetFile

func (cl *Client) GetFile(fileId string) File

func (*Client) GetMe

func (cl *Client) GetMe() Account

func (*Client) ParseWebhook

func (cl *Client) ParseWebhook(r io.Reader) (Webhook, error)

func (*Client) ReadFile

func (cl *Client) ReadFile(fileId string) File

type File

type File struct {
	ID      string `json:"file_id"`
	Size    int    `json:"file_size"`
	Path    string `json:"file_path"`
	Content string `json:"-"`
}

type FileResponse

type FileResponse struct {
	Ok   bool `json:"ok"`
	File File `json:"result"`
}

type Message

type Message struct {
	ID    int     `json:"message_id"`
	From  Account `json:"from"`
	Photo Photo   `json:"photo"`
}

type Photo

type Photo []PhotoVersion

type PhotoVersion

type PhotoVersion struct {
	FileID   string `json:"file_id"`
	FileSize int    `json:"file_size"`
	Width    int    `json:"width"`
	Height   int    `json:"height"`
}

type Webhook

type Webhook struct {
	ID      int     `json:"update_id"`
	Message Message `json:"message"`
}

func (Webhook) BestPhotoVersion

func (wh Webhook) BestPhotoVersion() PhotoVersion

Jump to

Keyboard shortcuts

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