telegram

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

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

Go to latest
Published: Jan 24, 2021 License: MIT Imports: 8 Imported by: 1

README

go-telegram-sender

A simple project to send messages to Telegram from Go projects

Use the go-retryablehttp to retry automatically when Telegram returns a 429 HTTP error

Usage

package main

import (
	"fmt"
	telegram "github.com/brincowale/go-telegram-sender"
)

func main() {
	t := telegram.New("BOT-API-KEY")
	err := t.SendMessage("@channelID", "Hello World!")
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println("OK")
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Request *http.Client
	Token   string
}

func New

func New(token string) Client

func (Client) SendMessage

func (c Client) SendMessage(chatId string, message string) error

type Message

type Message struct {
	ChatId string `json:"chat_id"`
	Text   string `json:"text"`
}

type TelegramResponse

type TelegramResponse struct {
	Ok          bool   `json:"ok"`
	ErrorCode   int    `json:"error_code"`
	Description string `json:"description"`
}

Jump to

Keyboard shortcuts

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