Skip to main content

Асинхронный клиент для NiosMess Bot Api

Project description

NiosBot

Hey guys! Welcome to the NiosBot API guide. This async library is super easy to use for building awesome bots on NiosMess. Let's dive right in!

1. Getting Ur Token

First things first, u need a token to connect ur bot. U can grab one right here: https://ni-os.ru/u/BotCreator. Pls keep it safe and private!

2. Installation

Just open up ur terminal and run: pip install nios-bot==0.1.4 It's latest version of nios-bot with a lot of fixed bugs;

3. Quick Start & Basics

This library runs asynchronously and uses httpx under the hood to handle requests[cite: 1]. By default, it connects to the base URL https://ni-os.ru/bot-api[cite: 1].

Here is a quick example of how to start ur bot and make it echo messages back[cite: 1]:

import asyncio
from nios_bot import NiosBot

# Initialize the bot with ur token
bot = NiosBot(token="your_token_here")

# Register a message handler
@bot.message_handler()
async def echo(message):
    chat_id = message["chat"]["id"]
    text = message.get("text", "")
    # Send the message back to the chat
    await bot.send_message(chat_id=chat_id, text=f"U just said: {text}")

async def main():
    # Start the polling loop so the bot listens for updates
    await bot.start_polling()

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

4. Available Methods

The NiosBot class provides several handy methods to interact with the API[cite: 1]:

  • Get Bot Info: Call await bot.get_me() to get info about ur bot[cite: 1].
  • Send Messages: Use await bot.send_message(chat_id, text) to send a text[cite: 1]. U can also pass an optional reply_markup dictionary or reply_to_message_id[cite: 1].
  • Edit Keyboards: Need to update an inline keyboard? Use await bot.edit_message_reply_markup(chat_id, message_id, reply_markup)[cite: 1].
  • Delete Messages: Remove a message using await bot.delete_message(chat_id, message_id)[cite: 1].
  • Chat Info: Retrieve details about a specific chat with await bot.get_chat(chat_id)[cite: 1].
  • Member Info: Check on a specific user in a chat via await bot.get_chat_member(chat_id, user_id)[cite: 1].

5. Handling Callback Queries

If ur bot uses inline keyboards, u will need to handle those button clicks. U can do this easily using the callback query decorator[cite: 1]:

@bot.callback_query_handler()
async def handle_button_click(callback):
    callback_id = callback["id"]
    
    # Always remember to answer the callback query!
    await bot.answer_callback_query(callback_query_id=callback_id, text="Action completed!")

Note: It is super important to call await bot.answer_callback_query() so the button doesn't just spin forever and show a loading state[cite: 1]. The text parameter is totally optional, but it's really useful for showing small pop-up notifications to the user[cite: 1].

Hope this helps u build something amazing!

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

nios_bot-0.1.4.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nios_bot-0.1.4-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file nios_bot-0.1.4.tar.gz.

File metadata

  • Download URL: nios_bot-0.1.4.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for nios_bot-0.1.4.tar.gz
Algorithm Hash digest
SHA256 30acd972c13c6e693cd058b2223fb39e01abee940656f61397f2dc864578380b
MD5 36273513d1c0fe66b7d4a1c6920312ba
BLAKE2b-256 05a296eb87814318c20b83dd7fab37c51a5d11feed99ec3785575cb48fa9b1b7

See more details on using hashes here.

File details

Details for the file nios_bot-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: nios_bot-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for nios_bot-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 55af34e6e6c3e1e8f804d918d7ad9abb31570d18768f219ebf6149eed925a007
MD5 37abebf782f66b3c1ae7a75d2ac502c8
BLAKE2b-256 b926af58e2c706f6cdc6d10cf7e91da28043c3495abf6ade72f0ae90350dcbfc

See more details on using hashes here.

Supported by

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