kamihi.tg.client
⚓︎
Telegram client module.
This module provides a Telegram client for sending messages and handling commands.
License
MIT
Classes:
| Name | Description |
|---|---|
TelegramClient |
Telegram client class. |
TelegramClient
⚓︎
TelegramClient(
_post_init: Callable, _post_shutdown: Callable
)
Telegram client class.
This class provides methods to send messages and handle commands.
Initialize the Telegram client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
callable
|
Function to call after the application is initialized. |
required |
|
callable
|
Function to call after the application is shut down. |
required |
Methods:
| Name | Description |
|---|---|
add_datasources |
Add data sources to the Telegram client. |
add_default_handlers |
Add default handlers to the Telegram client. |
add_handlers |
Add handlers to the Telegram client. |
add_jobs |
Add jobs to the Telegram client. |
add_pages_handler |
Add the pages handler to the Telegram client. |
reset_scopes |
Reset the command scopes for the bot. |
run |
Run the Telegram bot. |
run_job |
Run a job by its ID. |
set_scopes |
Set the command scopes for the bot. |
stop |
Stop the Telegram bot. |
Source code in src/kamihi/tg/client.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
add_datasources
⚓︎
add_datasources(datasources: dict[str, DataSource]) -> None
Add data sources to the Telegram client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict[str, DataSource]
|
Dictionary of data source names and their corresponding callables. |
required |
Source code in src/kamihi/tg/client.py
89 90 91 92 93 94 95 96 97 | |
add_default_handlers
⚓︎
add_default_handlers() -> None
Add default handlers to the Telegram client.
Source code in src/kamihi/tg/client.py
116 117 118 119 120 121 122 | |
add_handlers
⚓︎
add_handlers(handlers: list[BaseHandler]) -> None
Add handlers to the Telegram client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[BaseHandler]
|
List of handlers to add. |
required |
Source code in src/kamihi/tg/client.py
99 100 101 102 103 104 105 106 107 108 109 | |
add_jobs
⚓︎
add_jobs(
jobs: list[
tuple[
Job,
Callable[
[CallbackContext], Coroutine[Any, Any, None]
],
]
],
) -> None
Add jobs to the Telegram client.
Source code in src/kamihi/tg/client.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
add_pages_handler
⚓︎
add_pages_handler() -> None
Add the pages handler to the Telegram client.
Source code in src/kamihi/tg/client.py
111 112 113 114 | |
reset_scopes
async
⚓︎
reset_scopes() -> None
Reset the command scopes for the bot.
This method clears all command scopes and sets the default commands.
Source code in src/kamihi/tg/client.py
175 176 177 178 179 180 181 182 183 184 185 186 187 | |
run
⚓︎
run() -> None
Run the Telegram bot.
Source code in src/kamihi/tg/client.py
213 214 215 216 | |
run_job
async
⚓︎
run_job(job_id: str) -> None
Run a job by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The ID of the job to run. |
required |
Source code in src/kamihi/tg/client.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
set_scopes
async
⚓︎
set_scopes(scopes: dict[int, list[BotCommand]]) -> None
Set the command scopes for the bot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict[int, list[BotCommand]]
|
The command scopes to set. |
required |
Source code in src/kamihi/tg/client.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
stop
async
⚓︎
stop() -> None
Stop the Telegram bot.
Source code in src/kamihi/tg/client.py
218 219 220 221 | |