vkmax


Namevkmax JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
SummaryPython client for MAX messenger
upload_time2025-08-03 10:23:03
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords vk vkapi max-messenger vkmax oneme
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # vkmax
Python user client for VK MAX messenger (OneMe)

## What is VK MAX?
MAX (internal code name OneMe) is another project by the Russian government in an attempt to create a unified domestic messaging platform with features such as login via the government services account (Gosuslugi/ESIA).  
It is developed by VK Group.  

## What is `vkmax`?
This is a client library for MAX, allowing to create userbots and custom clients.  
An example of a simple userbot that retrieves weather can be found at [examples/weather-userbot](examples/weather-userbot).

## Installation
The package is [available on PyPI](https://pypi.org/project/vkmax/)  
`pip install vkmax`

## Usage
More in [examples](examples/)
```python
import asyncio
import logging

import requests
import sys

from vkmax.client import MaxClient
from vkmax.functions.messages import edit_message

from pathlib import Path


async def get_weather(city: str) -> str:
    response = requests.get(f"https://ru.wttr.in/{city}?Q&T&format=3")
    return response.text


async def packet_callback(client: MaxClient, packet: dict):
    if packet['opcode'] == 128:
        message_text: str = packet['payload']['message']['text']
        if message_text not in ['.info', '.weather']:
            return

        if message_text == ".info":
            text = "Userbot connected"

        elif ".weather" in message_text:
            city = message_text.split()[1]
            text = await get_weather(city)

        await edit_message(
            client,
            packet["payload"]["chatId"],
            packet["payload"]["message"]["id"],
            text
        )


async def main():
    client = MaxClient()

    await client.connect()

    login_token_file = Path('login_token.txt')

    if login_token_file.exists():
        login_token_from_file = login_token_file.read_text(encoding='utf-8').strip()
        try:
            await client.login_by_token(login_token_from_file)
        except:
            print("Couldn't login by token. Falling back to SMS login")

    else:
        phone_number = input('Enter your phone number: ')
        sms_login_token = await client.send_code(phone_number)
        sms_code = int(input('Enter SMS code: '))
        account_data = await client.sign_in(sms_login_token, sms_code)

        login_token = account_data['payload']['tokenAttrs']['LOGIN']['token']
        login_token_file.write_text(login_token, encoding='utf-8')

    await client.set_callback(packet_callback)

    await asyncio.Future()  # run forever


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

- [Protocol description](docs/protocol.md)
- [Known opcodes](docs/opcodes.md)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "vkmax",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "vk, vkapi, max-messenger, vkmax, oneme",
    "author": null,
    "author_email": "nsdkinx <nsdkinx@ya.ru>",
    "download_url": "https://files.pythonhosted.org/packages/e9/25/ef4d816a0e148e3c81bb4081cea6c03a5f95cd34e57e0fc560aad43e95be/vkmax-1.0.2.tar.gz",
    "platform": null,
    "description": "# vkmax\r\nPython user client for VK MAX messenger (OneMe)\r\n\r\n## What is VK MAX?\r\nMAX (internal code name OneMe) is another project by the Russian government in an attempt to create a unified domestic messaging platform with features such as login via the government services account (Gosuslugi/ESIA).  \r\nIt is developed by VK Group.  \r\n\r\n## What is `vkmax`?\r\nThis is a client library for MAX, allowing to create userbots and custom clients.  \r\nAn example of a simple userbot that retrieves weather can be found at [examples/weather-userbot](examples/weather-userbot).\r\n\r\n## Installation\r\nThe package is [available on PyPI](https://pypi.org/project/vkmax/)  \r\n`pip install vkmax`\r\n\r\n## Usage\r\nMore in [examples](examples/)\r\n```python\r\nimport asyncio\r\nimport logging\r\n\r\nimport requests\r\nimport sys\r\n\r\nfrom vkmax.client import MaxClient\r\nfrom vkmax.functions.messages import edit_message\r\n\r\nfrom pathlib import Path\r\n\r\n\r\nasync def get_weather(city: str) -> str:\r\n    response = requests.get(f\"https://ru.wttr.in/{city}?Q&T&format=3\")\r\n    return response.text\r\n\r\n\r\nasync def packet_callback(client: MaxClient, packet: dict):\r\n    if packet['opcode'] == 128:\r\n        message_text: str = packet['payload']['message']['text']\r\n        if message_text not in ['.info', '.weather']:\r\n            return\r\n\r\n        if message_text == \".info\":\r\n            text = \"Userbot connected\"\r\n\r\n        elif \".weather\" in message_text:\r\n            city = message_text.split()[1]\r\n            text = await get_weather(city)\r\n\r\n        await edit_message(\r\n            client,\r\n            packet[\"payload\"][\"chatId\"],\r\n            packet[\"payload\"][\"message\"][\"id\"],\r\n            text\r\n        )\r\n\r\n\r\nasync def main():\r\n    client = MaxClient()\r\n\r\n    await client.connect()\r\n\r\n    login_token_file = Path('login_token.txt')\r\n\r\n    if login_token_file.exists():\r\n        login_token_from_file = login_token_file.read_text(encoding='utf-8').strip()\r\n        try:\r\n            await client.login_by_token(login_token_from_file)\r\n        except:\r\n            print(\"Couldn't login by token. Falling back to SMS login\")\r\n\r\n    else:\r\n        phone_number = input('Enter your phone number: ')\r\n        sms_login_token = await client.send_code(phone_number)\r\n        sms_code = int(input('Enter SMS code: '))\r\n        account_data = await client.sign_in(sms_login_token, sms_code)\r\n\r\n        login_token = account_data['payload']['tokenAttrs']['LOGIN']['token']\r\n        login_token_file.write_text(login_token, encoding='utf-8')\r\n\r\n    await client.set_callback(packet_callback)\r\n\r\n    await asyncio.Future()  # run forever\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    asyncio.run(main())\r\n```\r\n\r\n- [Protocol description](docs/protocol.md)\r\n- [Known opcodes](docs/opcodes.md)\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python client for MAX messenger",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://github.com/nsdkinx/vkmax",
        "News": "https://t.me/max_messenger_python"
    },
    "split_keywords": [
        "vk",
        " vkapi",
        " max-messenger",
        " vkmax",
        " oneme"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "24032368e62e89c48c959ed62d96d658d7ab311b8f0966a7fc5aa4cb6e373ff8",
                "md5": "09ab5986751bf4a7e0cf41ff9134581a",
                "sha256": "fd4783d4f192c035168920b6e2705176afe59c41830c8c90dd7448ad25378462"
            },
            "downloads": -1,
            "filename": "vkmax-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "09ab5986751bf4a7e0cf41ff9134581a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 9437,
            "upload_time": "2025-08-03T10:23:01",
            "upload_time_iso_8601": "2025-08-03T10:23:01.715184Z",
            "url": "https://files.pythonhosted.org/packages/24/03/2368e62e89c48c959ed62d96d658d7ab311b8f0966a7fc5aa4cb6e373ff8/vkmax-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e925ef4d816a0e148e3c81bb4081cea6c03a5f95cd34e57e0fc560aad43e95be",
                "md5": "80c051f55a7f53a7d66c0600a579067e",
                "sha256": "a7d23be4d39b187bb9671d2d1d61061d9ca25ec5a37c7dd8129f262b6ad07e3e"
            },
            "downloads": -1,
            "filename": "vkmax-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "80c051f55a7f53a7d66c0600a579067e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 8828,
            "upload_time": "2025-08-03T10:23:03",
            "upload_time_iso_8601": "2025-08-03T10:23:03.006814Z",
            "url": "https://files.pythonhosted.org/packages/e9/25/ef4d816a0e148e3c81bb4081cea6c03a5f95cd34e57e0fc560aad43e95be/vkmax-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-03 10:23:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nsdkinx",
    "github_project": "vkmax",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "vkmax"
}
        
Elapsed time: 0.40123s