Examples

This page contains example scripts to show you what wzgram looks like in practice.

Every script is working right away (provided you correctly set up your credentials), meaning you can simply copy-paste and run. The only things you have to change are session names and target chats, where applicable.

Note

These scripts assume the session has already been authorized. A first login also needs api_id and api_hash passed to Client, bots included — see Authorization.

The examples listed below can be treated as building blocks for your own applications and are meant to be simple enough to give you a basic idea.


Example

Description

hello_world

Demonstration of basic API usage

echo_bot

Echo every private text message

business_echo_bot

Reply back the same message, in Business Chats

welcome_bot

An example Welcome Bot, updated to support the new Telegram Updates

get_history

Get the full message history of a chat

get_chat_members

Get all the members of a chat

get_dialogs

Get all of your dialog chats

callback_queries

Handle callback queries (as bot) coming from inline button presses

inline_queries

Handle inline queries (as bot) and answer with results

use_inline_bots

Query an inline bot (as user) and send a result to a chat

bot_keyboards

Send normal and inline keyboards using regular bots

send_voice

Download audio file and reupload as Voice Message with waveforms

raw_updates

Handle raw updates (old, should be avoided)

guest_message_echo_bot

Reply to guest messages, without joining the chat

conversation_bot

Ask questions and wait for the answers inline

ephemeral_message_bot

Reply in a group so that only one user sees it

rich_message

Send a structured document as a single message

Each feature page carries a working example of its own, and Advanced Usage covers calling raw TL functions directly when no high-level method exists yet.