Skip to main content

Limoo Python SDK

A Python SDK for Limoo.

Wondering what Limoo is? Visit https://limoo.im

Give Limoo a try: https://web.limoo.im

Install

pip install limoo-sdk

Example

The following is a simple echo bot. It listens to every conversation that it is a member of and will reply to every message that it receives in that conversation by echoing it back.

import asyncio
import contextlib

from limoo import LimooDriver

async def respond(event):
    # We only process events that inform us of new messages being created.
    # We have to make sure that the created message is not a system message and
    # that it was not created by us. Non-system messages have "null" as their
    # "type".
    if (event['event'] == 'message_created'
        and not (event['data']['message']['type']
                 or event['data']['message']['user_id'] == self['id'])):
        message_id = event['data']['message']['id']
        thread_root_id = event['data']['message']['thread_root_id']
        direct_reply_message_id = event['data']['message']['thread_root_id'] and event['data']['message']['id']
        # If the received message is part of a thread, it will have
        # thread_root_id set and we need to reuse that thread_root_id so that
        # our message ends up in the same thread. We also set
        # direct_reply_message_id to the id of the message so our message is
        # sent as a reply to the received message. If however, the received
        # message does not have thread_root_id set, we will create a new thread
        # by setting thread_root_id to the id of the received message. In this
        # case, we must set direct_reply_message_id to None.
        response = await ld.messages.create(
	    event['data']['workspace_id'],
	    event['data']['message']['conversation_id'],
	    event['data']['message']['text'],
	    thread_root_id=thread_root_id or message_id,
	    direct_reply_message_id=thread_root_id and message_id)

async def listen(ld):
    forever = asyncio.get_running_loop().create_future()
    # The given event_handler will be called on the event loop thread for each
    # event received from the WebSocket. Also it must be a normal function and
    # not a coroutine therefore we create our own task so that our coroutine
    # gets executed.
    ld.set_event_handler(lambda event: asyncio.create_task(respond(event)))
    await forever

async def main():
    global ld, self
    async with contextlib.AsyncExitStack() as stack:
        ld = LimooDriver('web.limoo.im', 'botusername', 'botpassword')
        stack.push_async_callback(ld.close)
        # Calling ld.users.get without any arguments gets information
        # about the currently logged in user
        self = await ld.users.get()
        await listen(ld)

asyncio.run(main())

API

Limoo API

The current version of the Limoo API is available at https://web.limoo.im/Limonad/api_reference/index.html which maps out the structure of the WebSocket events and the objects received from the methods in this SDK.

SDK

Right now the API is not yet stable so you should probably thoroughly test your code to make sure it still works with newer versions. Also we don't yet have a proper documentation but try and stick with what is documented in this file as everything else will probably not be part of the API.

Requirements

Bot creation

In order to create a bot, send the following command in your direct conversation with Limoo Bot:

/ساخت-بات my_bot bot_nickname

Note that only admins of the workspace can create bots.

Release files for limoo-sdk 0.2.4

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

Source distribution (sdist)

Source distribution for limoo-sdk 0.2.4
File Size Uploaded
limoo-sdk-0.2.4.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for limoo-sdk 0.2.4
File Interpreter ABI Platform
limoo_sdk-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 16.3 kB

Release files / limoo-sdk-0.2.4.tar.gz

Download URL limoo-sdk-0.2.4.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
69c22e7f2a5375528d7ebdcb1f915fcb60e037f6b24e7da6434c3a83c50e42c7
BLAKE2b-256 checksum
How to use checksums
d83ea03f7b62f9f32ccd87eb056d78f54b11478e641bd95cc9cd8cb7716ecfe9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.27.1

Release files / limoo_sdk-0.2.4-py3-none-any.whl

Download URL limoo_sdk-0.2.4-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b24155fbdb3dcf4036252ea9bc0eb3b440496987e8cf36fe238f508bc8635559
BLAKE2b-256 checksum
How to use checksums
cc451aeb9eb018dc150d2489a605a471ad31d350770385fa9a5e4170a55059d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.27.1

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

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