Signalbot¶
Python package to build your own Signal bots.
The package provides methods to easily listen for incoming messages and responding or reacting on them. It also provides a class to develop new commands, which then can be registered within the bot.
Here is minimal example of what that looks like:
import logging
import os
from signalbot import (
Command,
Config,
Context,
SignalBot,
enable_console_logging,
triggered,
)
class PingCommand(Command):
@triggered("Ping")
async def handle(self, c: Context) -> None:
await c.send("Pong")
if __name__ == "__main__":
enable_console_logging(logging.INFO)
bot = SignalBot(
Config(
signal_service=os.environ["SIGNAL_SERVICE"],
phone_number=os.environ["PHONE_NUMBER"],
)
)
bot.register(PingCommand()) # Run the command for all contacts and groups
bot.start()
To set it up follow the steps in the getting started page.
Methods overview¶
The bot can do a lot more, here is a quick overview of the most common methods:
bot.register(command, contacts=True, groups=True): Register a new command, listen in all contacts and groups, same asbot.register(command)bot.register(command, contacts=False, groups=["Hello World"]): Only listen in the "Hello World" groupbot.register(command, contacts=["+49123456789"], groups=False): Only respond to one contactbot.start(): Start the botbot.send(receiver, text): Send a new messagebot.react(message, emoji): React to a messagebot.start_typing(receiver): Start typingbot.stop_typing(receiver): Stop typingbot.send(receiver, text, edit_timestamp=timestamp): Edit a previously sent messagebot.remote_delete(receiver, timestamp): Delete a previously sent messagebot.receipt(message, receipt_type): Mark a message as readbot.update_group(group_id, avatar, description, expiration, name): Change group settingsbot.delete_attachment(attachment_filename): Delete the local copy of an attachmentbot.scheduler: Schedule tasks, see the scheduler examples.
Real world bot examples¶
There are many real world examples of bot implementations using this library. Check the whole list at https://github.com/signalbot-org/signalbot/network/dependents