Skip to main content

aioFunPayAPI

Полностью асинхронный форк оригинальной библиотеки FunPayAPI от LIMBODS, переписанный на asyncio и aiohttp для легкого написания неблокирующих ботов FunPay.

Установка

pip install aioFunPayAPI

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

Пример простого асинхронного бота, который отвечает на сообщение с текстом «привет»:

import asyncio
from aioFunPayAPI import Account, Runner
from aioFunPayAPI.enums import EventTypes

async def main():
    # Создаем класс аккаунта и асинхронно получаем его данные.
    acc = await Account(golden_key="YOUR_GOLDEN_KEY").get()
    print(f"Авторизован как {acc.username} (ID: {acc.id})")

    # Создаем прослушиватель событий.
    runner = Runner(acc)

    # Асинхронно прослушиваем события
    async for event in runner.listen(requests_delay=6.0):
        # Если событие — новое сообщение
        if event.type == EventTypes.NEW_MESSAGE:
            # Если текст сообщения "привет" и оно отправлено не нами
            if event.message.text and event.message.text.lower() == "привет" and event.message.author_id != acc.id:
                # Отправляем ответное сообщение асинхронно
                await acc.send_message(event.message.chat_id, "Ну привет...")
                runner.mark_as_by_bot(event.message.chat_id, event.message.id)

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

Выдача товара при новом заказе

Пример асинхронного бота, который выдает товар при новом оплаченном заказе:

import asyncio
from aioFunPayAPI import Account, Runner
from aioFunPayAPI.enums import EventTypes, OrderStatuses

async def main():
    acc = await Account(golden_key="YOUR_GOLDEN_KEY").get()
    runner = Runner(acc)

    async for event in runner.listen(requests_delay=6.0):
        # Если событие — новый заказ
        if event.type == EventTypes.NEW_ORDER:
            # Обязательно очищаем ID от знака '#'
            clean_id = event.order.id.replace("#", "")
            
            if event.order.status == OrderStatuses.PAID:
                order_info = await acc.get_order(clean_id)
                # Отправляем товар в чат покупателю
                await acc.send_message(
                    order_info.chat_id,
                    f"Привет, {event.order.buyer_username}!\nВот твой товар: ..."
                )

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

Release files for aioFunPayAPI 1.1.3

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

Source distribution (sdist)

Source distribution for aioFunPayAPI 1.1.3
File Size Uploaded
aiofunpayapi-1.1.3.tar.gz 46.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aioFunPayAPI 1.1.3
File Interpreter ABI Platform
aiofunpayapi-1.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 96.2 kB

Release files / aiofunpayapi-1.1.3.tar.gz

Download URL aiofunpayapi-1.1.3.tar.gz
Size 46.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ceec3ebf0c8cb408ced2d18bdefa2c980d2b67d46c7423aed65d0ea6bd9a5d52
BLAKE2b-256 checksum
How to use checksums
998dff229deaec8d03466b285f7a34111b0f53952b722eba5a50b0624ed0ab42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / aiofunpayapi-1.1.3-py3-none-any.whl

Download URL aiofunpayapi-1.1.3-py3-none-any.whl
Size 49.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d82dbdadd90fe544946ac5b22412e6e89182e4a53637d701abca61c45869627d
BLAKE2b-256 checksum
How to use checksums
d0f21ec9807439eef94128113ce71ed56e78360758c3aafcc4e6770d67bdc555
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

1.1.3 This release

2 release files

1.1.1

2 release files

1.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