Bob Bot

This module is the main entry point for the bot.

bobbot.get_debug_info() str[source]

Get the bot’s debug info.

bobbot.get_logger(name: str, level: int = 20, formatter: Formatter | None = None) Logger[source]

Get a logger with the specified name and logging level.

Parameters:
  • name – The name of the logger.

  • level – The logging level. Defaults to logging.INFO.

  • formatter – The log formatter to use. Defaults to a color formatter.

Returns:

The logger.

Example

>>> logger = get_logger(__name__)
>>> logger.info('Here is some info.')
2024-01-31 06:42:00 INFO     package.module Here is some info.
async bobbot.lazy_send_message(channel: TextChannel, message_str: str, instant: bool = False, force: bool = False) bool[source]

Send a message to a channel with typing time. Cancels the send on new messages or others typing.

If the message is too long, it will be split into chunks before sending. If instant is True, the message will be sent instantly (regardless of the bot’s mode). If force is True, the message will not be cancelled. Note that empty messages still won’t be sent.

Parameters:
  • channel – The channel to send the message to.

  • message_str – The message to send.

  • instant – Whether to try to send the message instantly. May still be cancelled.

  • force – Whether to force the message to be sent.

Returns:

Whether the message was sent in full.

async bobbot.query_memories(query: str, limit: int = 4, age_limit: timedelta | None = None, ignore_recent: bool = True, only_tools: bool = False) list[Document][source]

Search Bob’s long term memory for relevant, recent memories.

Most memories should not exceed ~5000 characters in length, but this is still a lot, and is also not guaranteed. Truncate all memories before giving them to an LLM!

Parameters:
  • query – The query to search for.

  • limit – The maximum number of memories to retrieve.

  • age_limit – The maximum age of the memories to retrieve. If None, all memories are considered.

  • ignore_recent – Whether to ignore recent memories (within 1 minute old) when retrieving.

  • only_tools – Whether to only retrieve tool memories.

Returns:

The list of retrieved memories, sorted by relevance.

bobbot.run_bot() None[source]

Run the bot. Blocks until the bot is stopped.