Skip to content

Commit 9075ba4

Browse files
SDK-40: Требуется добавить sendTyping в SDK Python
1 parent 2f39b18 commit 9075ba4

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-24.04
1515
strategy:
1616
matrix:
17-
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
17+
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
1818

1919
steps:
2020
- uses: actions/checkout@v3

examples/full.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def message_handler(notification: Notification) -> None:
2727
@bot.router.message(text_message=["1", "Report a problem"])
2828
def report_problem_handler(notification: Notification) -> None:
2929
notification.answer(
30-
"https://github.com/green-api/issues/issues/new", link_preview=False
30+
"https://github.com/green-api/issues/issues/new", link_preview=False, typing_time=2000
3131
)
3232

3333

@@ -47,7 +47,9 @@ def show_available_rates_handler(notification: Notification) -> None:
4747

4848
@bot.router.message(text_message=["4", "Call a support operator"])
4949
def call_support_operator_handler(notification: Notification) -> None:
50-
notification.answer("Good. A tech support operator will contact you soon.")
50+
notification.answer(
51+
"Good. A tech support operator will contact you soon.", typing_time=2000
52+
)
5153

5254
@bot.router.message(text_message=["5", "Show interactive buttons"])
5355
def show_interactive_buttons_handler(notification: Notification) -> None:

requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
whatsapp-api-client-python>=0.0.49
1+
whatsapp-api-client-python>=0.0.53
2+
aiogram>=3.21.0
3+
aiofiles>=24.1.0
4+
aiohttp>=3.9.0

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="whatsapp-chatbot-python",
8-
version="0.9.7",
8+
version="0.9.8",
99
description=(
1010
"This library helps you easily create"
1111
" a Python chatbot with WhatsApp API."
@@ -43,6 +43,6 @@
4343
"Creative Commons Attribution-NoDerivatives 4.0 International"
4444
" (CC BY-ND 4.0)"
4545
),
46-
install_requires=["whatsapp-api-client-python>=0.0.49"],
46+
install_requires=["whatsapp-api-client-python>=0.0.53"],
4747
python_requires=">=3.7"
4848
)

whatsapp_chatbot_python/manager/handler.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,13 @@ def answer(
8686
message: str,
8787
quoted_message_id: Optional[str] = None,
8888
archive_chat: Optional[bool] = None,
89-
link_preview: Optional[bool] = None
89+
link_preview: Optional[bool] = None,
90+
typing_time: Optional[int] = None
9091
) -> Optional[Response]:
9192
chat = self.get_chat()
9293
if chat:
9394
return self.api.sending.sendMessage(
94-
chat, message, quoted_message_id, archive_chat, link_preview
95+
chat, message, quoted_message_id, archive_chat, link_preview, typing_time
9596
)
9697

9798
def answer_buttons(
@@ -113,7 +114,7 @@ def answer_with_interactive_buttons(
113114
body: str,
114115
buttons: List[Dict[str, Union[str, Dict[str, str]]]],
115116
header: Optional[str] = None,
116-
footer: Optional[str] = None,
117+
footer: Optional[str] = None
117118
) -> Optional[Response]:
118119
chat = self.get_chat()
119120
if chat:
@@ -126,7 +127,7 @@ def answer_with_interactive_buttons_reply(
126127
body: str,
127128
buttons: List[Dict[str, str]],
128129
header: Optional[str] = None,
129-
footer: Optional[str] = None,
130+
footer: Optional[str] = None
130131
) -> Optional[Response]:
131132
chat = self.get_chat()
132133
if chat:
@@ -139,25 +140,28 @@ def answer_with_file(
139140
file: str,
140141
file_name: Optional[str] = None,
141142
caption: Optional[str] = None,
142-
quoted_message_id: Optional[str] = None
143+
quoted_message_id: Optional[str] = None,
144+
typing_time: Optional[int] = None,
145+
typing_type: Optional[str] = None
143146
) -> Optional[Response]:
144147
chat = self.get_chat()
145148
if chat:
146149
return self.api.sending.sendFileByUpload(
147-
chat, file, file_name, caption, quoted_message_id
150+
chat, file, file_name, caption, quoted_message_id, typing_time, typing_type
148151
)
149152

150153
def answer_with_poll(
151154
self,
152155
message: str,
153156
options: List[Dict[str, str]],
154157
multiple_answers: Optional[bool] = None,
155-
quoted_message_id: Optional[str] = None
158+
quoted_message_id: Optional[str] = None,
159+
typing_time: Optional[int] = None
156160
) -> Optional[Response]:
157161
chat = self.get_chat()
158162
if chat:
159163
return self.api.sending.sendPoll(
160-
chat, message, options, multiple_answers, quoted_message_id
164+
chat, message, options, multiple_answers, quoted_message_id, typing_time
161165
)
162166

163167
HandlerType = Callable[[Notification], Any]

0 commit comments

Comments
 (0)