multibotkit 0.1.7__py3-none-any.whl → 0.1.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,7 @@ from tenacity import (
13
13
  from multibotkit.helpers.base_helper import BaseHelper
14
14
  from multibotkit.schemas.telegram.outgoing import (
15
15
  Animation,
16
+ Audio,
16
17
  Document,
17
18
  EditMessageMediaModel,
18
19
  InlineKeyboardMarkup,
@@ -24,6 +25,7 @@ from multibotkit.schemas.telegram.outgoing import (
24
25
  SetWebhookParams,
25
26
  WebhookInfo,
26
27
  MediaGroup, ReplyKeyboardRemove,
28
+ Sticker
27
29
  )
28
30
 
29
31
 
@@ -1013,3 +1015,138 @@ class TelegramHelper(BaseHelper):
1013
1015
 
1014
1016
  r = await self._perform_async_request(url, data)
1015
1017
  return r
1018
+
1019
+ async def async_send_audio(
1020
+ self,
1021
+ chat_id: int,
1022
+ audio: str,
1023
+ file_name: Optional[str] = None,
1024
+ caption: Optional[str] = None,
1025
+ parse_mode: str = None,
1026
+ duration: Optional[int] = None,
1027
+ performer: Optional[str] = None,
1028
+ title: Optional[str] = None,
1029
+ thumbnail: Optional[str] = None,
1030
+ disable_notification: Optional[bool] = None,
1031
+ protect_content: Optional[bool] = None,
1032
+ reply_to_message_id: Optional[int] = None,
1033
+ allow_sending_without_reply: Optional[bool] = None,
1034
+ reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup]] = None
1035
+ ):
1036
+ files = {}
1037
+ audio_str = None
1038
+
1039
+ if type(audio) == str:
1040
+ if not (audio.startswith("http://") or audio.startswith("https://")):
1041
+ ends = [".mp3"]
1042
+ for end in ends:
1043
+ if audio.endswith(end):
1044
+ files["audio"] = (file_name if file_name else audio, open(audio, "rb"))
1045
+ audio_str = "attach://animation"
1046
+ if audio_str is None:
1047
+ audio_str = audio
1048
+ else:
1049
+ audio_str = "attach://animation"
1050
+ files["animation"] = (file_name if file_name else "file", audio)
1051
+
1052
+ audio_obj = Audio(
1053
+ chat_id=chat_id,
1054
+ audio=audio_str,
1055
+ caption=caption,
1056
+ parse_mode=parse_mode if parse_mode else "HTML",
1057
+ duration=duration,
1058
+ performer=performer,
1059
+ title=title,
1060
+ thumbnail=thumbnail,
1061
+ disable_notification=disable_notification,
1062
+ protect_content=protect_content,
1063
+ reply_to_message_id=reply_to_message_id,
1064
+ allow_sending_without_reply=allow_sending_without_reply,
1065
+ reply_markup=reply_markup
1066
+ )
1067
+
1068
+ url = self.tg_base_url + "sendAudio"
1069
+ data = audio_obj.dict(exclude_none=True)
1070
+ if "reply_markup" in data.keys():
1071
+ data["reply_markup"] = json.dumps(data["reply_markup"])
1072
+
1073
+ if len(files.keys()):
1074
+ r = await self._perform_async_request(url, data, use_json=False, files=files)
1075
+ return r
1076
+
1077
+ r = await self._perform_async_request(url, data)
1078
+ return r
1079
+
1080
+ async def async_send_sticker(
1081
+ self,
1082
+ chat_id: int,
1083
+ sticker: str,
1084
+ disable_notification: Optional[bool] = None,
1085
+ protect_content: Optional[bool] = None,
1086
+ reply_to_message_id: Optional[int] = None,
1087
+ allow_sending_without_reply: Optional[bool] = None,
1088
+ reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup]] = None
1089
+ ):
1090
+ sticker_obj = Sticker(
1091
+ chat_id=chat_id,
1092
+ sticker=sticker,
1093
+ disable_notification=disable_notification,
1094
+ protect_content=protect_content,
1095
+ reply_to_message_id=reply_to_message_id,
1096
+ allow_sending_without_reply=allow_sending_without_reply,
1097
+ reply_markup=reply_markup
1098
+ )
1099
+
1100
+ url = self.tg_base_url + "sendSticker"
1101
+ data = sticker_obj.dict(exclude_none=True)
1102
+ if "reply_markup" in data.keys():
1103
+ data["reply_markup"] = json.dumps(data["reply_markup"])
1104
+
1105
+ r = await self._perform_async_request(url, data)
1106
+ return r
1107
+
1108
+ def sync_send_sticker(
1109
+ self,
1110
+ chat_id: int,
1111
+ sticker: str,
1112
+ disable_notification: Optional[bool] = None,
1113
+ protect_content: Optional[bool] = None,
1114
+ reply_to_message_id: Optional[int] = None,
1115
+ allow_sending_without_reply: Optional[bool] = None,
1116
+ reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup]] = None
1117
+ ):
1118
+ sticker_obj = Sticker(
1119
+ chat_id=chat_id,
1120
+ sticker=sticker,
1121
+ disable_notification=disable_notification,
1122
+ protect_content=protect_content,
1123
+ reply_to_message_id=reply_to_message_id,
1124
+ allow_sending_without_reply=allow_sending_without_reply,
1125
+ reply_markup=reply_markup
1126
+ )
1127
+
1128
+ url = self.tg_base_url + "sendSticker"
1129
+ data = sticker_obj.dict(exclude_none=True)
1130
+ if "reply_markup" in data.keys():
1131
+ data["reply_markup"] = json.dumps(data["reply_markup"])
1132
+
1133
+ r = self._perform_sync_request(url, data)
1134
+ return r
1135
+
1136
+ def sync_get_sticker_set(
1137
+ self,
1138
+ sticker_set: str,
1139
+ ):
1140
+ url = self.tg_base_url + "getStickerSet"
1141
+ data = {"name": sticker_set}
1142
+ r = self._perform_sync_request(url, data)
1143
+ return r
1144
+
1145
+ async def async_get_sticker_set(
1146
+ self,
1147
+ sticker_set: str,
1148
+ ):
1149
+ url = self.tg_base_url + "getStickerSet"
1150
+ data = {"name": sticker_set}
1151
+ r = await self._perform_async_request(url, data)
1152
+ return r
@@ -202,3 +202,29 @@ class Animation(BaseModel):
202
202
  reply_to_message_id: Optional[int] = Field(None, title="reply to message id")
203
203
  allow_sending_without_reply: Optional[bool] = Field(None, title="allow sending without reply")
204
204
  reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup]] = Field(None, title="reply markup")
205
+
206
+
207
+ class Audio(BaseModel):
208
+ chat_id: int = Field(..., title="chat id")
209
+ audio: str = Field(..., title="document")
210
+ caption: Optional[str] = Field(None, title="caption")
211
+ parse_mode: str = Field("HTML", title="parse mode")
212
+ duration: Optional[int] = Field(None, title="Duration of sent animation in seconds")
213
+ performer: Optional[str] = Field(None, title="Performer")
214
+ title: Optional[str] = Field(None, title="Title")
215
+ thumbnail: Optional[str] = Field(None, title="document thumbnail")
216
+ disable_notification: Optional[bool] = Field(None, title="disable notification")
217
+ protect_content: Optional[bool] = Field(None, title="protect content")
218
+ reply_to_message_id: Optional[int] = Field(None, title="reply to message id")
219
+ allow_sending_without_reply: Optional[bool] = Field(None, title="allow sending without reply")
220
+ reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup]] = Field(None, title="reply markup")
221
+
222
+
223
+ class Sticker(BaseModel):
224
+ chat_id: int = Field(..., title="chat id")
225
+ sticker: str = Field(..., title="document")
226
+ disable_notification: Optional[bool] = Field(None, title="disable notification")
227
+ protect_content: Optional[bool] = Field(None, title="protect content")
228
+ reply_to_message_id: Optional[int] = Field(None, title="reply to message id")
229
+ allow_sending_without_reply: Optional[bool] = Field(None, title="allow sending without reply")
230
+ reply_markup: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup]] = Field(None, title="reply markup")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: multibotkit
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary: Functional library for developing multiplatform chatbots
5
5
  Home-page: https://github.com/Appvelox/multibotkit
6
6
  Author: Appvelox LLC
@@ -8,7 +8,7 @@ multibotkit/dispatchers/vk.py,sha256=EsFOL2g3ju-nhsdyRY4JBTJxqQPmaPAB7Mkn462s4tk
8
8
  multibotkit/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  multibotkit/helpers/base_helper.py,sha256=b4vlmwELwGUIJE0DvD2Lkk0LO-b-w0VWAnEnnYawOKQ,1462
10
10
  multibotkit/helpers/fb.py,sha256=Z2Vo6A_fepVBQNcWCeelmH72zf_eKyXOXheUIlaIiBI,4329
11
- multibotkit/helpers/telegram.py,sha256=6IKtZ2FYzUs9FuOynYdjAiXn5MqZYSfrtfbppZg1o2Q,37652
11
+ multibotkit/helpers/telegram.py,sha256=7zJnJ5IHykuA_DaAGAV75z35t36D7rMJGvoxrOCZy8I,42592
12
12
  multibotkit/helpers/viber.py,sha256=74UQ3RtHS3iR8qA5XVeMOYfXaaMq2pF0cpItwehdr4o,9246
13
13
  multibotkit/helpers/vk.py,sha256=QlI9rGEjhzqS-jcFrnZJ651lDbC4m33SSHAC1zWDyUU,5930
14
14
  multibotkit/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -17,7 +17,7 @@ multibotkit/schemas/fb/incoming.py,sha256=sp4CeQohaDMOxz113dNxJDv_fSaGW5i8qzVS7F
17
17
  multibotkit/schemas/fb/outgoing.py,sha256=Qm0gPHHipAolXpnOJC4J4bfYjQEWpX54vYygSwKtIV4,8036
18
18
  multibotkit/schemas/telegram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  multibotkit/schemas/telegram/incoming.py,sha256=mLZ55IHvalbI_CpSv1QhtsWEBjPKYAH9FP2uYWfDSqE,10379
20
- multibotkit/schemas/telegram/outgoing.py,sha256=1DSmgs5oq1Tonlp6XRQch0JCvbKbcaIJ8UdmRZtVKpg,7952
20
+ multibotkit/schemas/telegram/outgoing.py,sha256=Iv1KCwR_28ugd1GkKrJHgPVP2zblKFYwh03hmajg1Is,9492
21
21
  multibotkit/schemas/viber/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  multibotkit/schemas/viber/incoming.py,sha256=0sS9g-NmQFl_uoVz8pkbQ9zdNsXvGE52KxmzADoFIRM,4193
23
23
  multibotkit/schemas/viber/outgoing.py,sha256=KI73IX-aawtAx3ejW2Hx0ivXBYuMVudUxhwyp1wv6rc,8252
@@ -31,8 +31,8 @@ multibotkit/states/managers/base.py,sha256=KOO-wtbj984-lLq6u6LhxR79NTftQV2c5uUG6
31
31
  multibotkit/states/managers/memory.py,sha256=uN064uj2Q0ivK9LGEHJFaaaG6FEyXkIajS87TCAuYsI,1328
32
32
  multibotkit/states/managers/mongo.py,sha256=K8upbLT0892YA2Qi9dDPXDP5jvQoS16T8FW-qapv1Xk,1927
33
33
  multibotkit/states/managers/redis.py,sha256=C9HTjfVvttzOizycprWHd2C86DfKqd2Nyq5-5CqQNDI,1659
34
- multibotkit-0.1.7.dist-info/LICENSE,sha256=3iCLdX93Z5F6PpDqN6q7wufsBixXuTAYwgzntBQjYBQ,1069
35
- multibotkit-0.1.7.dist-info/METADATA,sha256=7oD5p9S5Xiee7QV9lRPrOtHNjQptbwWhy3WOALsiJ_A,851
36
- multibotkit-0.1.7.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
37
- multibotkit-0.1.7.dist-info/top_level.txt,sha256=Meo5tTNdc5pf6_qwW6x4Cqz5iJJlXFqUDMti96pzV2I,12
38
- multibotkit-0.1.7.dist-info/RECORD,,
34
+ multibotkit-0.1.9.dist-info/LICENSE,sha256=3iCLdX93Z5F6PpDqN6q7wufsBixXuTAYwgzntBQjYBQ,1069
35
+ multibotkit-0.1.9.dist-info/METADATA,sha256=-xXxqZlO6VHBs1maQU3ase9ewh32mlK9JCEi19erzXM,851
36
+ multibotkit-0.1.9.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
37
+ multibotkit-0.1.9.dist-info/top_level.txt,sha256=Meo5tTNdc5pf6_qwW6x4Cqz5iJJlXFqUDMti96pzV2I,12
38
+ multibotkit-0.1.9.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.38.4)
2
+ Generator: bdist_wheel (0.40.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5