Skip to main content

Read the latest Real Python tutorials

Project description

Shadpy
Shad API Framework for Python
Homepage Documentation Releases

Shad Api

Elegant, modern and asynchronous Shad API framework in Python for users and bots

Accounts

WebSocket Handler:

from shadapi import Client

app = Client('my_account_auth')

@app.handler
async def my_bot(bot, message):
    await message.reply('``Hello`` __from__ **Shad Api**!')

Messages Update Handler:

from shadapi import Client

app = Client('my_account_auth')

@app.updateHandler
async def my_bot(bot, message):
    await message.reply('``Hello`` __from__ **Shad Api**!')

OR

from shadapi import Client

app = Client('my_account_auth')

update_delay = 5 # in seconds

@app.updateHandler(update_delay)
async def my_bot(bot, message):
    await message.reply('``Hello`` __from__ **Shad Api**!')

Another example:

from shadapi import Client

app = Client("my_account_auth")

async def my_bot(bot):
    await bot.sendText('object_guid', '``Hello`` __from__ **Shad Api**!')

app.run(my_bot)

Bots Examples (ONLY FOR SPECIAL MEMBERS) (NOT TESTED)

from shadapi import Bot

app = Bot('token')

async def my_bot(bot):
    me = await bot.getMe()
    print(me)

app.run(my_bot)

OR

from shadapi import Bot

app = Bot('token')

async def my_bot(bot):
    me = await bot.sendMessage('chat_id', 'text')
    print(me)

app.run(my_bot)

Shad-Api is a modern, elegant and asynchronous framework. It enables you to easily interact with the main Shad API through a user account (custom client) or a bot identity (bot API alternative) using Python.

Key Features

  • Ready: Install Shad-Api with pip and start building your applications right away.
  • Easy: Makes the Shad API simple and intuitive, while still allowing advanced usages.
  • Elegant: Low-level details are abstracted and re-presented in a more convenient way.
  • Fast: Boosted up by pycryptodome, a high-performance cryptography library written in C.
  • Async: Fully asynchronous (also usable synchronously if wanted, for convenience).
  • Powerful: Full access to Shad's API to execute any official client action and more.

Installing

pip3 install shadapi

Notes

broken message handler

when using this library for fethcing messages from a chat, the library will start a WebSocket channel with the server, and because of the present lag in the server, some of the messages will not be sent by the server and wont be processed by the client (this is not an issue with the library, it's from the server! this problem also do exist in the Android and Web versions of Shad) we can kindof fix this problem by loading every last message every once in a while to ensure that the client have recived every message, but this would make the bot use more internet (around 277MB per day for maden requests every 2 seconds). the problem with this bypass is that the server would consider that as "request spam" (aka DDOS) and will refuse to response to most of the requests, and this would make the bot pretty much slower! i did implement this functionality in the library and with the addition of "request delay", but until shad devs fix the main issue inside the server or until i find an actuall bypass solution, this are the only ways to handle messages in this library.

Request method advantages disadvantage
WebSocket syncing instant trigger ignores most messages
getChatUpdates request triggers on every message slow trigger

Thanks to:

shayanheidari01

he did an awesome job at making a rubika library which helped alot to make this project! https://github.com/shayanheidari01/rubika

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shadapi-0.2.0.tar.gz (139.9 kB view details)

Uploaded Source

Built Distribution

shadapi-0.2.0-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file shadapi-0.2.0.tar.gz.

File metadata

  • Download URL: shadapi-0.2.0.tar.gz
  • Upload date:
  • Size: 139.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for shadapi-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0b18d8e5fef98f2ec6f6087a4c795dea4d5319b7bdd508fbe25c54f0085bd2de
MD5 618baad874e2f511f38f6bb25d541f4d
BLAKE2b-256 088c2af80cd9a9b4d79a9c3e882ab3f9e23d871c083e8f3a3d4a7ca4df9fe6eb

See more details on using hashes here.

File details

Details for the file shadapi-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: shadapi-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 28.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for shadapi-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4f790159a1960c4662f843b05a2accdc4099277d22e4c2485ca78b90ce984b5
MD5 3be14fcb589e5dc316fcd3403f47ad4a
BLAKE2b-256 6526a3819f1d45064ad7c5c5a2d47e77ba78a05859e6d896047ec609a630c689

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page