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 — текст сообщения (всегда 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.7

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

Built distribution (wheel)

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

Total release size: 619.5 kB

Release files / wintergram_userbot-1.7.tar.gz

Download URL wintergram_userbot-1.7.tar.gz
Size 303.9 kB
Tags Source
SHA-256 checksum
How to use checksums
31d05fff4ec7d95be4f50345dfac57ac8aa2d2b0083917d4e25051f0c2b60cb6
BLAKE2b-256 checksum
How to use checksums
c64a2293cbf4c761764dc3934a33cce700353294ab2e9c349fa7e91848041981
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.7-py3-none-any.whl

Download URL wintergram_userbot-1.7-py3-none-any.whl
Size 315.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db46dd12b059656d299fa3c8a16e4d83b939c9647fe7a54fb6096eb08b54cc10
BLAKE2b-256 checksum
How to use checksums
50318a4179ec05099a6068f65637a986bc29b651ddd0949d0c705c15d3decda6
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.7

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