Skip to main content

wintergram-userbot

Асинхронный MTProto-клиент для приватных Telegram-серверов, написанный с нуля на Python.

Особенности

  • ✅ Полная поддержка MTProto — layers 167-228
  • ✅ Асинхронный — построен на asyncio
  • ✅ Приватные серверы — работает с кастомными MTProto-серверами
  • ✅ События — NewMessage, MessageEdited, MessageDeleted
  • ✅ Userbot режим — реагирует на свои собственные сообщения
  • ✅ Редактирование сообщений — полная поддержка edit_message

Установка

pip install wintergram-userbot

Быстрый старт

import asyncio
from wintergram_userbot import WinterGramClient
from wintergram_userbot.api.updates import NewMessage

async def main():
    client = WinterGramClient()

    @client.on(NewMessage)
    async def on_message(event):
        if event.out and ".test" in (event.text or "").lower():
            # Редактируем своё сообщение
            chat = event.sender_id if event.is_private else event.chat_id
            await client.edit_message(chat, event.id, "userbot работает")

    phone = input("Номер телефона (с '+'): ")
    await client.start(phone=phone)

    print("Бот запущен!")
    try:
        while True:
            await asyncio.sleep(3600)
    except KeyboardInterrupt:
        pass
    finally:
        await client.disconnect()

if __name__ == "__main__":
    asyncio.run(main())

Документация

События

NewMessage

Новое сообщение в чате:

@client.on(NewMessage)
async def handler(event):
    print(f"Сообщение: {event.text}")
    print(f"От: {event.sender_id}")
    print(f"Чат: {event.chat_id}")
    print(f"Исходящее: {event.out}")

MessageEdited

Редактирование сообщения:

@client.on(MessageEdited)
async def handler(event):
    print(f"Отредактировано: {event.text}")

MessageDeleted

Удаление сообщения:

@client.on(MessageDeleted)
async def handler(event):
    print(f"Удалены: {event.deleted_ids}")

Методы клиента

send_message

Отправка сообщения:

await client.send_message(chat_id, "Текст сообщения")
await client.send_message("me", "В Избранное")

edit_message

Редактирование сообщения:

await client.edit_message(chat_id, message_id, "Новый текст")

get_history

Получение истории чата:

history = await client.get_history(chat_id, limit=50)

Свойства события

  • event.id — ID сообщения
  • event.text — текст сообщения (bytes или str)
  • event.date — время отправки
  • event.chat_id — ID чата
  • event.sender_id — ID отправителя
  • event.out — True если это ваше сообщение
  • event.is_private — True если личное сообщение
  • event.is_channel — True если сообщение из канала
  • event.from_channel — True если отправлено каналом

Требования

  • Python 3.8+
  • asyncio

Лицензия

MIT License

Автор

femboychik

Поддержка

Вопросы и issue: GitHub Issues

Release files for wintergram-userbot 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wintergram-userbot 1.0.0
File Size Uploaded
wintergram_userbot-1.0.0.tar.gz 290.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wintergram-userbot 1.0.0
File Interpreter ABI Platform
wintergram_userbot-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 595.5 kB

Release files / wintergram_userbot-1.0.0.tar.gz

Download URL wintergram_userbot-1.0.0.tar.gz
Size 290.1 kB
Tags Source
SHA-256 checksum
How to use checksums
da77b61fc593749f7b862a42d3b1b9b63e6dde375d8c49f9152424592754f52c
BLAKE2b-256 checksum
How to use checksums
e956ac7d2f301da9d123a85094d056896bf83336f236fc24c0ff59519ab8cc8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / wintergram_userbot-1.0.0-py3-none-any.whl

Download URL wintergram_userbot-1.0.0-py3-none-any.whl
Size 305.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03989752c7e588f611776133ae51c404d32254255f055d89d051ef4faf160b31
BLAKE2b-256 checksum
How to use checksums
0efb2d4210851842a3b78dc09e73b2cb520d6640b403c73d9400632e3d41094d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page