Skip to content

Config

Config

Bases: BaseModel

The configuration for SignalBot.

Attributes:

Name Type Description
signal_service str

The URL of the signal-cli-rest-api service to connect to.

phone_number str

The phone number of the bot.

storage RedisConfig | SQLiteConfig | InMemoryConfig | None

The configuration for the storage backend to use. Defaults to None.

retry_interval int

The interval in seconds to wait before retrying a failed connection to the signal service.

download_attachments bool

Whether to download attachments from messages. Defaults to True.

connection_mode ConnectionMode

The connection mode to use when connecting to the Signal service. Defaults to ConnectionMode.AUTO.

Source code in src/signalbot/bot_config.py
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
class Config(BaseModel):
    """
    The configuration for SignalBot.

    Attributes:
        signal_service: The URL of the `signal-cli-rest-api` service to connect to.
        phone_number: The phone number of the bot.
        storage: The configuration for the storage backend to use. Defaults to `None`.
        retry_interval: The interval in seconds to wait before retrying a failed
            connection to the signal service.
        download_attachments: Whether to download attachments from messages. Defaults to
            `True`.
        connection_mode: The connection mode to use when connecting to the Signal
            service. Defaults to `ConnectionMode.AUTO`.
    """

    signal_service: str
    phone_number: str

    storage: RedisConfig | SQLiteConfig | InMemoryConfig | None = None
    retry_interval: int = 1
    download_attachments: bool = True
    connection_mode: ConnectionMode = ConnectionMode.AUTO

InMemoryConfig

Bases: BaseModel

The configuration for the in-memory storage backend.

Attributes:

Name Type Description
type Literal['in-memory']

The type of storage.

Source code in src/signalbot/bot_config.py
43
44
45
46
47
48
49
50
51
class InMemoryConfig(BaseModel):
    """
    The configuration for the in-memory storage backend.

    Attributes:
        type: The type of storage.
    """

    type: Literal["in-memory"] = "in-memory"

RedisConfig

Bases: BaseModel

The configuration for the Redis storage backend.

Attributes:

Name Type Description
type Literal['redis']

The type of storage.

redis_host str

The hostname of the Redis server.

redis_port int

The port number of the Redis server.

Source code in src/signalbot/bot_config.py
13
14
15
16
17
18
19
20
21
22
23
24
25
class RedisConfig(BaseModel):
    """
    The configuration for the Redis storage backend.

    Attributes:
        type: The type of storage.
        redis_host: The hostname of the Redis server.
        redis_port: The port number of the Redis server.
    """

    type: Literal["redis"] = "redis"
    redis_host: str
    redis_port: int

SQLiteConfig

Bases: BaseModel

The configuration for the SQLite storage backend.

Attributes:

Name Type Description
type Literal['sqlite']

The type of storage.

sqlite_db str | Path

The path to the SQLite database file.

check_same_thread bool

Whether to check the same thread when accessing the database.

Source code in src/signalbot/bot_config.py
28
29
30
31
32
33
34
35
36
37
38
39
40
class SQLiteConfig(BaseModel):
    """
    The configuration for the SQLite storage backend.

    Attributes:
        type: The type of storage.
        sqlite_db: The path to the SQLite database file.
        check_same_thread: Whether to check the same thread when accessing the database.
    """

    type: Literal["sqlite"] = "sqlite"
    sqlite_db: str | Path
    check_same_thread: bool = True

ConnectionMode

Bases: str, Enum

Protocol strategy for connecting to signal-cli-rest-api.

Attributes:

Name Type Description
HTTPS_ONLY

Always use HTTPS/WSS.

HTTP_ONLY

Always use HTTP/WS.

AUTO

Start with HTTPS/WSS and fallback to HTTP/WS if unavailable.

Source code in src/signalbot/api.py
14
15
16
17
18
19
20
21
22
23
24
25
class ConnectionMode(str, Enum):
    """Protocol strategy for connecting to `signal-cli-rest-api`.

    Attributes:
        HTTPS_ONLY: Always use HTTPS/WSS.
        HTTP_ONLY: Always use HTTP/WS.
        AUTO: Start with HTTPS/WSS and fallback to HTTP/WS if unavailable.
    """

    HTTPS_ONLY = "https_only"
    HTTP_ONLY = "http_only"
    AUTO = "auto"