examples

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2021 License: MIT Imports: 3 Imported by: 4

README

Examples

Most examples use environment variable client builders. You can do it manually, see bot-auth-manual for example.

  1. Obtain api_id and api_hash for your application and set as APP_ID, APP_HASH
  2. Set SESSION_FILE to something like ~/session.yourbot.json for persistent auth
  3. Run example.

Please don't share APP_ID or APP_HASH, it can't be easily rotated.

Name Description Features
auth User authentication from terminal input Custom UserAuthenticator
bot-auth-manual Bot authentication session.Storage, setup without environment variables
bot-echo Echo bot UpdateDispatcher, message sender
bot-upload One-shot uploader for bot NoUpdates flag, uploads with MIME, custom file name and as audio, resolving peer by username, HTML message
gif-download Saved gif backup (and restore) for user Download, upload, middlewares with rate limit, unpack
bg-run Using client without Run contrib/bg package
pretty-print Pretty-print requests, responses and updates The tgp package, middleware and custom UpdateHandler for all updates

Environment variables

Name Description
BOT_TOKEN Token from BotFather
APP_ID api_id of Telegram app from my.telegram.org
APP_HASH api_hash of Telegram app from my.telegram.org
SESSION_FILE Path to session file, like /home/super-bot/.gotd/session.super-bot.json
SESSION_DIR Path to session directory, if SESSION_FILE is not set, like /home/super-bot/.gotd

Support

Still don't know how to use specific features? See user support.

Documentation

Overview

Package examples contains usage examples for gotd features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(f func(ctx context.Context, log *zap.Logger) error)

Run runs f callback with context and logger, panics on error.

Types

This section is empty.

Directories

Path Synopsis
Binary auth implements authentication example for user using terminal.
Binary auth implements authentication example for user using terminal.
bg-run module
Binary bot-auth-manual implements example of custom session storage and manually setting up client options without environment variables.
Binary bot-auth-manual implements example of custom session storage and manually setting up client options without environment variables.
Binary bot-echo implements basic example for bot.
Binary bot-echo implements basic example for bot.
Binary bot-upload implements upload example for bot.
Binary bot-upload implements upload example for bot.
gif-download module

Jump to

Keyboard shortcuts

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