Skip to main content

wintergram-userbot

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

Особенности

  • ✅ Полная поддержка MTProto — layers 167-232
  • ✅ Асинхронный — построен на 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 — текст сообщения (всегда 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 если отправлено каналом
  • event.message — внутренний dict сообщения (текст тоже str)

Требования

  • Python 3.8+
  • asyncio

Лицензия

MIT License

Автор

femboychik

Поддержка

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

Metadata

Release files for wintergram-userbot 1.8

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.8
File Size Uploaded Provenance
wintergram_userbot-1.8.tar.gz 305.1 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 622.0 kB

Release files / wintergram_userbot-1.8.tar.gz

Download URL wintergram_userbot-1.8.tar.gz
Size 305.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4f2f87f53d82c439b78f64ab45627a02b6c944c1dced1d17386c93f94d1019a9
BLAKE2b-256 checksum
How to use checksums
3750377d4e7a551a3c98afd0e7b10b41db298d6ddd9d0758703bfce2ea151ee3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

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

Download URL wintergram_userbot-1.8-py3-none-any.whl
Size 316.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
accfcc20e80d5acc89906f1b45c0c09f3086d74099e185b2f407777f884a63ef
BLAKE2b-256 checksum
How to use checksums
88e59fd50a31104043c991aa3ab5a7675f6e72cecd84b45398a08c21d0d5533a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for wintergram-userbot 1.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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