Skip to content

Config

BasicAuth

Bases: BaseModel

The configuration for username and password based authentication.

Attributes:

Name Type Description
type Literal['basic']

The type of authentication. Defaults to basic.

username str

The username for the authentication.

password str

The password used for authentication.

Source code in src/signalbot/bot_config.py
56
57
58
59
60
61
62
63
64
65
66
67
68
class BasicAuth(BaseModel):
    """
    The configuration for username and password based authentication.

    Attributes:
        type: The type of authentication. Defaults to `basic`.
        username: The username for the authentication.
        password: The password used for authentication.
    """

    type: Literal["basic"] = "basic"
    username: str
    password: str

BearerAuth

Bases: BaseModel

The configuration for token based authentication.

Attributes:

Name Type Description
type Literal['bearer']

The type of authentication. Defaults to bearer.

token str

The token used for authentication.

Source code in src/signalbot/bot_config.py
71
72
73
74
75
76
77
78
79
80
81
class BearerAuth(BaseModel):
    """
    The configuration for token based authentication.

    Attributes:
        type: The type of authentication. Defaults to `bearer`.
        token: The token used for authentication.
    """

    type: Literal["bearer"] = "bearer"
    token: str

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.

auth BasicAuth | BearerAuth | None

The authentication config used for http requests. Defaults to None.

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
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
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.
        auth: The authentication config used for http requests. Defaults to `None`.
        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
    auth: BasicAuth | BearerAuth | None = None

    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. Defaults to in-memory.

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

    Attributes:
        type: The type of storage. Defaults to `in-memory`.
    """

    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. Defaults to redis.

redis_host str

The hostname of the Redis server.

redis_port int

The port number of the Redis server.

redis_password str | None

The password for Redis authentication. Defaults to None.

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

    Attributes:
        type: The type of storage. Defaults to `redis`.
        redis_host: The hostname of the Redis server.
        redis_port: The port number of the Redis server.
        redis_password: The password for Redis authentication. Defaults to `None`.
    """

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

SQLiteConfig

Bases: BaseModel

The configuration for the SQLite storage backend.

Attributes:

Name Type Description
type Literal['sqlite']

The type of storage. Defaults to sqlite.

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
30
31
32
33
34
35
36
37
38
39
40
41
42
class SQLiteConfig(BaseModel):
    """
    The configuration for the SQLite storage backend.

    Attributes:
        type: The type of storage. Defaults to `sqlite`.
        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
16
17
18
19
20
21
22
23
24
25
26
27
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"