Skip to content

Commit 3e439f3

Browse files
committed
Updated docs
1 parent cc62f86 commit 3e439f3

2 files changed

Lines changed: 124 additions & 0 deletions

File tree

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,24 @@ bot = GreenAPIBot(
4646
)
4747
```
4848

49+
### How to enable debug mode
50+
51+
```
52+
bot = GreenAPIBot(
53+
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345",
54+
bot_debug_mode=True
55+
)
56+
```
57+
58+
You can also enable API debug mode:
59+
60+
```
61+
bot = GreenAPIBot(
62+
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345",
63+
debug_mode=True, bot_debug_mode=True
64+
)
65+
```
66+
4967
### How to set up an instance
5068

5169
To start receiving incoming notifications, you need to set up an instance. Open the personal cabinet page at
@@ -314,6 +332,50 @@ def password_handler(notification: Notification) -> None:
314332
bot.run_forever()
315333
```
316334

335+
### FAQ
336+
337+
- How to call API methods?
338+
339+
```
340+
bot.api.account.getSettings()
341+
```
342+
343+
Or
344+
345+
```
346+
notification.api.account.getSettings()
347+
```
348+
349+
- How do I disable error raising?
350+
351+
```
352+
bot = GreenAPIBot(
353+
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345",
354+
raise_errors=False
355+
)
356+
```
357+
358+
- How do I subscribe only to text messages?
359+
360+
You need to import the required constants first:
361+
362+
```
363+
from whatsapp_chatbot_python.filters import TEXT_TYPES
364+
```
365+
366+
Then add this filter: `type_message=TEXT_TYPES`.
367+
368+
- How do I get the message text and sender ID?
369+
370+
This data is in the notification object (`notification`):
371+
372+
```
373+
@bot.router.message()
374+
def message_handler(notification: Notification) -> None:
375+
print(notification.sender)
376+
print(notification.message_text)
377+
```
378+
317379
### Example of a bot
318380

319381
As an example, a bot was created to support the GREEN API. Command list:

docs/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ bot = GreenAPIBot(
4545
)
4646
```
4747

48+
### Как включить режим отладки
49+
50+
```
51+
bot = GreenAPIBot(
52+
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345",
53+
bot_debug_mode=True
54+
)
55+
```
56+
57+
Также можно включить режим отладки API:
58+
59+
```
60+
bot = GreenAPIBot(
61+
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345",
62+
debug_mode=True, bot_debug_mode=True
63+
)
64+
```
65+
4866
### Как настроить инстанс
4967

5068
Чтобы начать получать входящие уведомления, нужно настроить инстанс. Открываем страницу личного кабинета
@@ -313,6 +331,50 @@ def password_handler(notification: Notification) -> None:
313331
bot.run_forever()
314332
```
315333

334+
### Часто задаваемые вопросы
335+
336+
- Как вызвать методы API?
337+
338+
```
339+
bot.api.account.getSettings()
340+
```
341+
342+
Или
343+
344+
```
345+
notification.api.account.getSettings()
346+
```
347+
348+
- Как отключить вызов ошибок?
349+
350+
```
351+
bot = GreenAPIBot(
352+
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345",
353+
raise_errors=False
354+
)
355+
```
356+
357+
- Как подписаться только на текстовые сообщения?
358+
359+
Нужно сначала импортировать нужные константы:
360+
361+
```
362+
from whatsapp_chatbot_python.filters import TEXT_TYPES
363+
```
364+
365+
Затем добавить этот фильтр: `type_message=TEXT_TYPES`.
366+
367+
- Как получить текст сообщения и ID отправителя?
368+
369+
Эти данные есть в объекте уведомления (`notification`):
370+
371+
```
372+
@bot.router.message()
373+
def message_handler(notification: Notification) -> None:
374+
print(notification.sender)
375+
print(notification.message_text)
376+
```
377+
316378
### Пример бота
317379

318380
В качестве примера был создан бот для поддержки GREEN API. Список команд:

0 commit comments

Comments
 (0)