Skip to main content

A bot for rocketchat messaging, allowing you to react to messages or commands.

Project description

Rocketbotte

A bot for rocketchat messaging, allowing you to react to messages or commands.

It works with rocketchat's realtime api (websocket) to receive messages, and responds with the REST api. To do this, it uses the aiohttp python library.

Installation

pip install rocketbotte

Usage

from rocketbotte import Bot, Context, Message

bot = Bot(server_url=SERVER_URL, user_id=USER_ID, auth_token=AUTH_TOKEN)

@bot.command('test')
async def test(ctx:Context, args:str):
    await ctx.send_message(f'response to {args}')

@bot.listen()
async def on_message(message:Message):
    if 'hello' in message.content:
        await bot.send_message(message.room_id, 'world ')

bot.run()

events and listenners

events can be trigged with bot.fire_event(event_name:str) method or created by adding a listenner self.add_listener(func:Coroutine, name:str, [aliases:list]) or by the annotation @bot.listen. Three events are already defined or trigged in the process :

  • on_message, fired on new message
  • on_command, fired when a command is trigged in a message, already defined with bot.on_command function
  • on_ready, fired when the bot is ready
  • on_close, never fired, , already defined with bot.on_close function which close the websocket service

Bot parameters

  • server_url: the server url as https://myrocketchat.org
  • auth_token: the personal authentification token for the bot
  • command_prefix: default : '!'
  • user_id: the user id who belongs to the authentification token
  • max_retry: number of attempt restart after an uncaught exception, default to 5
  • max_retry_time: seconds before new attemps of connexion, default to 30
  • max_off_time: time in seconds since last ping from server worth a new connection, defaut te 120

logging

This library use loguru for logging. To see logs explicit ask for by using logger.enable("rocketbotte")

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

rocketbotte-0.2.4.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

rocketbotte-0.2.4-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file rocketbotte-0.2.4.tar.gz.

File metadata

  • Download URL: rocketbotte-0.2.4.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for rocketbotte-0.2.4.tar.gz
Algorithm Hash digest
SHA256 39772c966d2061d9614944175806cbc00978f36e093d9507fe8e794c0d035dd2
MD5 53017c50085f21022fd92af72244b6d0
BLAKE2b-256 d22ea0b4851c00b5cdb9839c0715b5d0f0665eeb1df17283f08cb966c3423915

See more details on using hashes here.

File details

Details for the file rocketbotte-0.2.4-py3-none-any.whl.

File metadata

File hashes

Hashes for rocketbotte-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a0a23e6f0c7584f58d977548599cd3993db5c8e99f648065f31b7a39d50f2bc7
MD5 386eadcc06c40832ed186816b69f4de7
BLAKE2b-256 1e8bbba87563e8b93734f5b327464db91734794fdd0257fd23558fdc37d3b45c

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