Rubka 6.6.2__py3-none-any.whl → 7.1.17__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.
- rubka/__init__.py +70 -0
- rubka/api.py +6 -17
- rubka/asynco.py +1058 -255
- rubka/button.py +1 -1
- rubka/context.py +560 -25
- rubka/exceptions.py +35 -1
- rubka/filters.py +16 -0
- rubka/helpers.py +1461 -0
- rubka/metadata.py +117 -0
- rubka/rubino.py +227 -96
- rubka/tv.py +145 -0
- rubka/update.py +560 -25
- {rubka-6.6.2.dist-info → rubka-7.1.17.dist-info}/METADATA +29 -11
- {rubka-6.6.2.dist-info → rubka-7.1.17.dist-info}/RECORD +17 -13
- rubka-7.1.17.dist-info/entry_points.txt +2 -0
- {rubka-6.6.2.dist-info → rubka-7.1.17.dist-info}/WHEEL +0 -0
- {rubka-6.6.2.dist-info → rubka-7.1.17.dist-info}/top_level.txt +0 -0
rubka/metadata.py
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from typing import Any, Dict, List
|
|
3
|
+
import markdownify
|
|
4
|
+
def _normalize_multiline_quote(text: str) -> str:
|
|
5
|
+
lines = text.splitlines()
|
|
6
|
+
normalized_lines = []
|
|
7
|
+
quote_block = []
|
|
8
|
+
|
|
9
|
+
for line in lines + [""]:
|
|
10
|
+
if line.startswith(">"):quote_block.append(line[1:].strip())
|
|
11
|
+
else:
|
|
12
|
+
if quote_block:
|
|
13
|
+
normalized_lines.append("$" + "\n".join(quote_block) + "$")
|
|
14
|
+
quote_block = []
|
|
15
|
+
normalized_lines.append(line)
|
|
16
|
+
return "\n".join(normalized_lines).strip()
|
|
17
|
+
|
|
18
|
+
class Track_parsed:
|
|
19
|
+
_PATT = re.compile(
|
|
20
|
+
r"(?P<pre>```(?P<pre_c>[\s\S]*?)```)"
|
|
21
|
+
r"|(?P<bold>\*\*(?P<bold_c>.*?)\*\*)"
|
|
22
|
+
r"|(?P<mono>`(?P<mono_c>.*?)`)"
|
|
23
|
+
r"|(?P<italic>__(?P<italic_c>.*?)__)"
|
|
24
|
+
r"|(?P<underline>--(?P<underline_c>.*?)--)"
|
|
25
|
+
r"|(?P<link>\[(?P<link_text>.*?)\]\((?P<link_url>\S+?)\))"
|
|
26
|
+
r"|(?P<quote>\$(?P<quote_c>[\s\S]*?)\$)"
|
|
27
|
+
r"|(?P<quote_md>^>(?P<quote_md_c>.*?)(?:\n|$))"
|
|
28
|
+
r"|(?P<strike>~~(?P<strike_c>.*?)~~)"
|
|
29
|
+
r"|(?P<spoiler>\|\|(?P<spoiler_c>.*?)\|\|)",
|
|
30
|
+
flags=re.DOTALL,
|
|
31
|
+
)
|
|
32
|
+
_TYPE_MAP = {
|
|
33
|
+
"pre": "Pre",
|
|
34
|
+
"bold": "Bold",
|
|
35
|
+
"mono": "Mono",
|
|
36
|
+
"italic": "Italic",
|
|
37
|
+
"underline": "Underline",
|
|
38
|
+
"strike": "Strike",
|
|
39
|
+
"spoiler": "Spoiler",
|
|
40
|
+
"quote": "Quote",
|
|
41
|
+
"quote_md": "Quote",
|
|
42
|
+
"link": "Link",
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@staticmethod
|
|
46
|
+
def _utf16_len_java_style(s: str) -> int:
|
|
47
|
+
return len(s.encode("utf-16-be")) // 2
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def _html2md(src: str) -> str:
|
|
51
|
+
src = re.sub(r'<i>(.*?)</i>', r'||\1||', src, flags=re.DOTALL)
|
|
52
|
+
src = re.sub(r'<span class="spoiler">(.*?)</span>', r'||\1||', src, flags=re.DOTALL)
|
|
53
|
+
src = markdownify.markdownify(html=src).strip()
|
|
54
|
+
src = src.replace("@@SPOILER@@", "||")
|
|
55
|
+
return src
|
|
56
|
+
|
|
57
|
+
def transcribe(self, src: str, mode: str = "MARKDOWN") -> Dict[str, Any]:
|
|
58
|
+
if mode and mode.upper() == "HTML":
|
|
59
|
+
src = self._html2md(src)
|
|
60
|
+
src = _normalize_multiline_quote(src)
|
|
61
|
+
|
|
62
|
+
payload_parts: List[Dict[str, Any]] = []
|
|
63
|
+
|
|
64
|
+
normalized_text = src
|
|
65
|
+
byte_offset = 0
|
|
66
|
+
char_offset = 0
|
|
67
|
+
|
|
68
|
+
matches = list(self._PATT.finditer(src))
|
|
69
|
+
for m in matches:
|
|
70
|
+
whole = m.group(0)
|
|
71
|
+
start, end = m.span()
|
|
72
|
+
adj_from = self._utf16_len_java_style(src[:start]) - byte_offset
|
|
73
|
+
adj_char_from = start - char_offset
|
|
74
|
+
|
|
75
|
+
gname = m.lastgroup
|
|
76
|
+
if not gname:
|
|
77
|
+
continue
|
|
78
|
+
|
|
79
|
+
if gname == "link":
|
|
80
|
+
inner = m.group("link_text") or ""
|
|
81
|
+
link_href = m.group("link_url")
|
|
82
|
+
else:
|
|
83
|
+
inner = m.group(f"{gname}_c") or ""
|
|
84
|
+
link_href = None
|
|
85
|
+
if gname in ["quote", "quote_md", "bold", "italic", "underline", "spoiler", "strike"]:
|
|
86
|
+
inner_metadata = self.transcribe(inner, mode="MARKDOWN")
|
|
87
|
+
inner = inner_metadata["text"]
|
|
88
|
+
if "metadata" in inner_metadata:
|
|
89
|
+
for part in inner_metadata["metadata"]["meta_data_parts"]:
|
|
90
|
+
part["from_index"] += adj_from
|
|
91
|
+
payload_parts.append(part)
|
|
92
|
+
if inner == "":
|
|
93
|
+
continue
|
|
94
|
+
content_utf16_len = self._utf16_len_java_style(inner)
|
|
95
|
+
part: Dict[str, Any] = {
|
|
96
|
+
"type": self._TYPE_MAP.get(gname, "Unknown"),
|
|
97
|
+
"from_index": adj_from,
|
|
98
|
+
"length": content_utf16_len,
|
|
99
|
+
}
|
|
100
|
+
if link_href:
|
|
101
|
+
part["link_url"] = link_href
|
|
102
|
+
payload_parts.append(part)
|
|
103
|
+
normalized_text = (
|
|
104
|
+
normalized_text[:adj_char_from] + inner + normalized_text[end - char_offset :]
|
|
105
|
+
)
|
|
106
|
+
byte_offset += self._utf16_len_java_style(whole) - content_utf16_len
|
|
107
|
+
char_offset += (end - start) - len(inner)
|
|
108
|
+
|
|
109
|
+
result: Dict[str, Any] = {"text": normalized_text.strip()}
|
|
110
|
+
if payload_parts:
|
|
111
|
+
result["metadata"] = {"meta_data_parts": payload_parts}
|
|
112
|
+
|
|
113
|
+
return result
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def parse(self, text: str, parse_mode: str = "MARKDOWN") -> Dict[str, Any]:
|
|
117
|
+
return self.transcribe(text, mode=parse_mode)
|
rubka/rubino.py
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import urllib3
|
|
2
|
-
import json
|
|
3
|
-
from typing import Any, Dict
|
|
2
|
+
import json,random
|
|
3
|
+
from typing import Any, Dict,List
|
|
4
4
|
from tempfile import NamedTemporaryFile
|
|
5
5
|
from os import system, chmod, remove
|
|
6
6
|
from base64 import b64encode
|
|
7
7
|
from io import BytesIO
|
|
8
|
+
class InvalidInputError(Exception):
|
|
9
|
+
def __init__(self, message="Invalid input provided"):
|
|
10
|
+
self.message = message
|
|
11
|
+
super().__init__(self.message)
|
|
8
12
|
class confing():
|
|
9
13
|
headers= {
|
|
10
14
|
"User-Agent": "okhttp/3.12.1",
|
|
@@ -192,9 +196,15 @@ class req:
|
|
|
192
196
|
except:
|
|
193
197
|
continue
|
|
194
198
|
else:
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
199
|
+
|
|
200
|
+
response_data = response.json()
|
|
201
|
+
|
|
202
|
+
if 'data_enc' in response_data:
|
|
203
|
+
return loads(self.enc.decrypt(response_data['data_enc']))
|
|
204
|
+
if response_data.get('status') != "OK":
|
|
205
|
+
raise InvalidInputError(f"Error : {response_data.get('status_det', 'Unknown error')}")
|
|
206
|
+
return response_data
|
|
207
|
+
|
|
198
208
|
|
|
199
209
|
def requestUploadFile(self,file_name:str,size:str,file_type:str,profile_id:str=None):
|
|
200
210
|
return self.send_request({
|
|
@@ -203,6 +213,7 @@ class req:
|
|
|
203
213
|
"file_type": file_type,
|
|
204
214
|
"profile_id": profile_id
|
|
205
215
|
},"requestUploadFile")
|
|
216
|
+
|
|
206
217
|
|
|
207
218
|
def upload(self, post_file, post_type: str, profile_id: str = None):
|
|
208
219
|
file_byte_code = post_file if isinstance(post_file, bytes) else open(post_file, "rb").read()
|
|
@@ -406,28 +417,14 @@ class api:
|
|
|
406
417
|
response_data = json.loads(response.data.decode('utf-8'))
|
|
407
418
|
if 'result' in response_data:
|
|
408
419
|
return response_data['result']
|
|
409
|
-
|
|
410
|
-
resp = get(
|
|
411
|
-
url="https://www.google.com/search",
|
|
412
|
-
headers={
|
|
413
|
-
"User-Agent": get_useragent()
|
|
414
|
-
},
|
|
415
|
-
params={
|
|
416
|
-
"q": term,
|
|
417
|
-
"num": results + 2, # Prevents multiple requests
|
|
418
|
-
"hl": lang,
|
|
419
|
-
"start": start,
|
|
420
|
-
},
|
|
421
|
-
proxies=proxies,
|
|
422
|
-
timeout=timeout,
|
|
423
|
-
)
|
|
424
|
-
resp.raise_for_status()
|
|
425
|
-
return resp
|
|
426
|
-
import random
|
|
420
|
+
|
|
427
421
|
|
|
428
422
|
class Bot():
|
|
429
|
-
"""rubino class"""
|
|
423
|
+
"""rubino class Regester m.rubika.ir"""
|
|
430
424
|
def __init__(self,auth,platform="m.rubika.ir",lang_code="fa") -> None:
|
|
425
|
+
"""
|
|
426
|
+
regester m.rubika.ir
|
|
427
|
+
"""
|
|
431
428
|
self.auth=auth
|
|
432
429
|
self.platform=platform
|
|
433
430
|
self.lang_code=lang_code
|
|
@@ -446,7 +443,7 @@ class Bot():
|
|
|
446
443
|
"api_version":"0",
|
|
447
444
|
"client":{
|
|
448
445
|
"app_name":"Main",
|
|
449
|
-
"app_version":"2.
|
|
446
|
+
"app_version":"2.4.7",
|
|
450
447
|
"package":"m.rubika.ir",
|
|
451
448
|
"platform":"PWA"
|
|
452
449
|
},
|
|
@@ -473,11 +470,12 @@ class Bot():
|
|
|
473
470
|
if response.status == 200:
|
|
474
471
|
response_data = json.loads(response.data.decode('utf-8'))
|
|
475
472
|
if 'data' in response_data:
|
|
476
|
-
|
|
473
|
+
return response_data['data']
|
|
477
474
|
else:
|
|
478
|
-
|
|
479
|
-
else
|
|
480
|
-
raise Exception("Request Error Server")
|
|
475
|
+
raise Exception(f"Error: {response_data.get('status_det', 'Unknown error')}")
|
|
476
|
+
else:
|
|
477
|
+
raise Exception(f"Request Error Server - Status Code: {response.status}")
|
|
478
|
+
|
|
481
479
|
def edit_info_page(
|
|
482
480
|
self,
|
|
483
481
|
username_me:str,
|
|
@@ -660,6 +658,49 @@ class Bot():
|
|
|
660
658
|
return [668,789]
|
|
661
659
|
except Exception as e:
|
|
662
660
|
return [668,789]
|
|
661
|
+
def add_Story(self,post_file:str,duration:int=27,size:list=[668,798],thumbnail_file:str=None,profile_id:str=None):
|
|
662
|
+
|
|
663
|
+
if post_file.split(".")[-1] == "mp4" or post_file.split(".")[-1] == "mov" or post_file.split(".")[-1] == "mkv" or "https://":
|
|
664
|
+
try:
|
|
665
|
+
if "https://" in post_file:
|
|
666
|
+
tumb_res , post_res = req(self.auth).upload(image_to_bytes(thumbnail_file) if type(thumbnail_file) is str else confing.th,"Picture",profile_id) , req(self.auth).upload(requests.get(post_file).content,"Video",profile_id)
|
|
667
|
+
else :
|
|
668
|
+
tumb_res , post_res = req(self.auth).upload(image_to_bytes(thumbnail_file) if type(thumbnail_file) is str else confing.th,"Picture",profile_id) , req(self.auth).upload(post_file,"Video",profile_id)
|
|
669
|
+
except ModuleNotFoundError:
|
|
670
|
+
print("pip install moviepy")
|
|
671
|
+
tumb_res , post_res = req(self.auth).upload(confing.th,"Picture",profile_id) , req(self.auth).upload(post_file,"Video",profile_id)
|
|
672
|
+
data = {
|
|
673
|
+
"duration": str(duration),
|
|
674
|
+
"file_id": post_res[0]["file_id"],
|
|
675
|
+
"hash_file_receive": post_res[1],
|
|
676
|
+
"height": 1280 if size[1] > 1280 else size[1],
|
|
677
|
+
"story_type": "Video",
|
|
678
|
+
"rnd": random.randint(100000, 999999999),
|
|
679
|
+
"snapshot_file_id": tumb_res[0]["file_id"],
|
|
680
|
+
"snapshot_hash_file_receive": tumb_res[1],
|
|
681
|
+
"thumbnail_file_id": tumb_res[0]["file_id"],
|
|
682
|
+
"thumbnail_hash_file_receive": tumb_res[1],
|
|
683
|
+
"width": 720 if size[0] > 720 else size[0],
|
|
684
|
+
"profile_id": profile_id
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
elif post_file.split(".")[-1] == "jpg" or post_file.split(".")[-1] == "png":
|
|
688
|
+
post_res = req(self.auth).upload(post_file,"Picture",profile_id)
|
|
689
|
+
|
|
690
|
+
data = {
|
|
691
|
+
"file_id": post_res[0]["file_id"],
|
|
692
|
+
"hash_file_receive": post_res[1],
|
|
693
|
+
"height": 1280 if size[1] > 1280 else size[1],
|
|
694
|
+
"story_type": "Picture",
|
|
695
|
+
"rnd": random.randint(100000, 999999999),
|
|
696
|
+
"thumbnail_file_id": post_res[0]["file_id"],
|
|
697
|
+
"thumbnail_hash_file_receive": post_res[1],
|
|
698
|
+
"width": 720 if size[0] > 720 else size[0],
|
|
699
|
+
"profile_id": profile_id
|
|
700
|
+
}
|
|
701
|
+
else:
|
|
702
|
+
return "file address eror"
|
|
703
|
+
return req(self.auth).send_request(data,"addStory")['data']
|
|
663
704
|
def add_Post(self,post_file: str, caption: str = None, time: int = 1, size: Any = [668, 798], thumbnail_file: str = None, profile_id: str = None):
|
|
664
705
|
from concurrent.futures import ThreadPoolExecutor
|
|
665
706
|
if size == "Auto" or size =="auto":
|
|
@@ -891,6 +932,22 @@ class Bot():
|
|
|
891
932
|
"target_profile_id": target_profile_id,
|
|
892
933
|
"profile_id": profile_id
|
|
893
934
|
},methode="getProfileFollowers")
|
|
935
|
+
def search_Follower(self,username,profile_id,target_profile_id,limit=10,search_type="Follower"):
|
|
936
|
+
return self._reuests_post(data={
|
|
937
|
+
"limit": limit,
|
|
938
|
+
"profile_id": profile_id,
|
|
939
|
+
"search_type": limit,
|
|
940
|
+
"target_profile_id": target_profile_id,
|
|
941
|
+
"username": username
|
|
942
|
+
},methode="searchFollower")
|
|
943
|
+
def search_Following(self,username,profile_id,target_profile_id,limit=10,search_type="Following"):
|
|
944
|
+
return self._reuests_post(data={
|
|
945
|
+
"limit": limit,
|
|
946
|
+
"profile_id": profile_id,
|
|
947
|
+
"search_type": limit,
|
|
948
|
+
"target_profile_id": target_profile_id,
|
|
949
|
+
"username": username
|
|
950
|
+
},methode="searchFollower")
|
|
894
951
|
|
|
895
952
|
def get_Page_Following(self,target_profile_id:str,sort:str="FromMax",limit:int=50,equal:bool=False,profile_id:str=None):
|
|
896
953
|
return self._reuests_post(data={
|
|
@@ -925,28 +982,30 @@ class Bot():
|
|
|
925
982
|
"username": username,
|
|
926
983
|
"profile_id": profile_id
|
|
927
984
|
},methode="getProfileFollowers")
|
|
928
|
-
|
|
929
|
-
def get_NewFollow_Requests(self,sort:str="FromMax",limit:int=50,equal:bool=False,profile_id:str=None):
|
|
985
|
+
def get_Related_Explore_Post(self,post_id:str,track_id,post_profile_id:str,limit:int=50,start_id:bool=False,profile_id:str=None,target_profile_id=None,):
|
|
930
986
|
return self._reuests_post(data={
|
|
931
|
-
"equal": equal,
|
|
932
987
|
"limit": limit,
|
|
933
|
-
"
|
|
988
|
+
"post_id": post_id,
|
|
989
|
+
"post_profile_id": post_profile_id,
|
|
990
|
+
"start_id": start_id,
|
|
991
|
+
"target_profile_id": target_profile_id,
|
|
992
|
+
"track_id": track_id,
|
|
934
993
|
"profile_id": profile_id
|
|
935
|
-
},methode="
|
|
994
|
+
},methode="getRelatedExplorePost")
|
|
936
995
|
|
|
937
|
-
def
|
|
996
|
+
def get_Highlight_StoryIds(self,highlight_id:str,profile_id:str,target_profile_id:str):
|
|
938
997
|
return self._reuests_post(data={
|
|
939
|
-
"
|
|
940
|
-
"
|
|
941
|
-
"
|
|
942
|
-
},methode="
|
|
943
|
-
|
|
944
|
-
def decline_Request_Follow(self,request_id:str,profile_id:str=None):
|
|
998
|
+
"highlight_id": highlight_id,
|
|
999
|
+
"profile_id": profile_id,
|
|
1000
|
+
"target_profile_id": target_profile_id
|
|
1001
|
+
},methode="getHighlightStoryIds")
|
|
1002
|
+
def get_Highlight_Stories(self,highlight_id:str,profile_id:str,target_profile_id:str,story_ids:list):
|
|
945
1003
|
return self._reuests_post(data={
|
|
946
|
-
"
|
|
947
|
-
"
|
|
948
|
-
"
|
|
949
|
-
|
|
1004
|
+
"highlight_id": highlight_id,
|
|
1005
|
+
"profile_id": profile_id,
|
|
1006
|
+
"target_profile_id": target_profile_id,
|
|
1007
|
+
"story_ids":story_ids
|
|
1008
|
+
},methode="getHighlightStories")
|
|
950
1009
|
def un_save_Post(self,post_profile_id:str,post_id:str,profile_id:str=None):
|
|
951
1010
|
return self._reuests_post(data={
|
|
952
1011
|
"action_type": "Unbookmark",
|
|
@@ -955,14 +1014,24 @@ class Bot():
|
|
|
955
1014
|
"track_id": "Related",
|
|
956
1015
|
"profile_id": profile_id
|
|
957
1016
|
},methode="postBookmarkAction")
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
1017
|
+
def get_saved_posts(
|
|
1018
|
+
self,
|
|
1019
|
+
max_id: str,
|
|
1020
|
+
limit: int = 20,
|
|
1021
|
+
profile_id: Optional[str] = None,
|
|
1022
|
+
sort: str = "FromMax") -> Dict[str, Any]:
|
|
1023
|
+
payload = {
|
|
962
1024
|
"limit": limit,
|
|
963
|
-
"
|
|
964
|
-
"
|
|
965
|
-
}
|
|
1025
|
+
"max_id": max_id,
|
|
1026
|
+
"sort": sort
|
|
1027
|
+
}
|
|
1028
|
+
if profile_id is not None:
|
|
1029
|
+
payload["profile_id"] = profile_id
|
|
1030
|
+
|
|
1031
|
+
return self._reuests_post(
|
|
1032
|
+
data=payload,
|
|
1033
|
+
methode="getBookmarkedPosts"
|
|
1034
|
+
)
|
|
966
1035
|
|
|
967
1036
|
def search_Page(self,username:str,sort:str="FromMax",limit:int=50,equal:bool=False,profile_id:str=None):
|
|
968
1037
|
return self._reuests_post(data={
|
|
@@ -994,6 +1063,14 @@ class Bot():
|
|
|
994
1063
|
"record_id": post_id,
|
|
995
1064
|
"profile_id": profile_id
|
|
996
1065
|
},methode="setReportRecord")
|
|
1066
|
+
def report_Post(self,post_profile_id,post_id:str,reason:int=2,profile_id:str=None):
|
|
1067
|
+
return self._reuests_post(data={
|
|
1068
|
+
"model": "Post",
|
|
1069
|
+
"reason": reason,
|
|
1070
|
+
"post_profile_id":post_profile_id,
|
|
1071
|
+
"record_id": post_id,
|
|
1072
|
+
"profile_id": profile_id
|
|
1073
|
+
},methode="setReportRecord")
|
|
997
1074
|
|
|
998
1075
|
def delete_Post(self,post_id:str,profile_id:str=None):
|
|
999
1076
|
return self._reuests_post(data={
|
|
@@ -1013,6 +1090,12 @@ class Bot():
|
|
|
1013
1090
|
"profile_status": profile_status,
|
|
1014
1091
|
"profile_id": profile_id
|
|
1015
1092
|
},methode="updateProfile")
|
|
1093
|
+
def get_New_Events(self,limit:int=20,sort:str="FromMax",profile_id:str=None):
|
|
1094
|
+
return self._reuests_post(data={
|
|
1095
|
+
"limit": limit,
|
|
1096
|
+
"profile_id": profile_id,
|
|
1097
|
+
"sort":sort
|
|
1098
|
+
},methode="updateProfile")
|
|
1016
1099
|
|
|
1017
1100
|
def allow_Send_MessagePv(self,is_message_allowed:bool=False,profile_id:str=None):
|
|
1018
1101
|
return self._reuests_post(data={
|
|
@@ -1035,49 +1118,7 @@ class Bot():
|
|
|
1035
1118
|
"thumbnail_hash_file_receive": prof_res[1],
|
|
1036
1119
|
"profile_id": profile_id
|
|
1037
1120
|
},methode="updateProfilePhoto")
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
if post_file.split(".")[-1] == "mp4" or post_file.split(".")[-1] == "mov" or post_file.split(".")[-1] == "mkv" or "https://":
|
|
1041
|
-
try:
|
|
1042
|
-
if "https://" in post_file:
|
|
1043
|
-
tumb_res , post_res = req(self.auth).upload(image_to_bytes(thumbnail_file) if type(thumbnail_file) is str else confing.th,"Picture",profile_id) , req(self.auth).upload(requests.get(post_file).content,"Video",profile_id)
|
|
1044
|
-
else :
|
|
1045
|
-
tumb_res , post_res = req(self.auth).upload(image_to_bytes(thumbnail_file) if type(thumbnail_file) is str else confing.th,"Picture",profile_id) , req(self.auth).upload(post_file,"Video",profile_id)
|
|
1046
|
-
except ModuleNotFoundError:
|
|
1047
|
-
print("pip install moviepy")
|
|
1048
|
-
tumb_res , post_res = req(self.auth).upload(confing.th,"Picture",profile_id) , req(self.auth).upload(post_file,"Video",profile_id)
|
|
1049
|
-
data = {
|
|
1050
|
-
"duration": str(duration),
|
|
1051
|
-
"file_id": post_res[0]["file_id"],
|
|
1052
|
-
"hash_file_receive": post_res[1],
|
|
1053
|
-
"height": 1280 if size[1] > 1280 else size[1],
|
|
1054
|
-
"story_type": "Video",
|
|
1055
|
-
"rnd": random.randint(100000, 999999999),
|
|
1056
|
-
"snapshot_file_id": tumb_res[0]["file_id"],
|
|
1057
|
-
"snapshot_hash_file_receive": tumb_res[1],
|
|
1058
|
-
"thumbnail_file_id": tumb_res[0]["file_id"],
|
|
1059
|
-
"thumbnail_hash_file_receive": tumb_res[1],
|
|
1060
|
-
"width": 720 if size[0] > 720 else size[0],
|
|
1061
|
-
"profile_id": profile_id
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
elif post_file.split(".")[-1] == "jpg" or post_file.split(".")[-1] == "png":
|
|
1065
|
-
post_res = req(self.auth).upload(post_file,"Picture",profile_id)
|
|
1066
|
-
|
|
1067
|
-
data = {
|
|
1068
|
-
"file_id": post_res[0]["file_id"],
|
|
1069
|
-
"hash_file_receive": post_res[1],
|
|
1070
|
-
"height": 1280 if size[1] > 1280 else size[1],
|
|
1071
|
-
"story_type": "Picture",
|
|
1072
|
-
"rnd": random.randint(100000, 999999999),
|
|
1073
|
-
"thumbnail_file_id": post_res[0]["file_id"],
|
|
1074
|
-
"thumbnail_hash_file_receive": post_res[1],
|
|
1075
|
-
"width": 720 if size[0] > 720 else size[0],
|
|
1076
|
-
"profile_id": profile_id
|
|
1077
|
-
}
|
|
1078
|
-
else:
|
|
1079
|
-
return "file address eror"
|
|
1080
|
-
return req(self.auth).send_request(data,"addStory")['data']
|
|
1121
|
+
|
|
1081
1122
|
def delete_Page(self,page_profile_id:str):
|
|
1082
1123
|
return self._reuests_post(data={
|
|
1083
1124
|
"model": "Profile",
|
|
@@ -1097,4 +1138,94 @@ class Bot():
|
|
|
1097
1138
|
"post_id": post_id,
|
|
1098
1139
|
"post_profile_id": post_profile_id,
|
|
1099
1140
|
"profile_id": profile_id
|
|
1100
|
-
},methode="addPostViewTime")['data']
|
|
1141
|
+
},methode="addPostViewTime")['data']
|
|
1142
|
+
def get_Profile_Posts(self,target_profile_id:str,max_id:str,sort:str="FromMax",limit:str=10):
|
|
1143
|
+
return self._reuests_post(data={
|
|
1144
|
+
"limit": limit,
|
|
1145
|
+
"max_id": max_id,
|
|
1146
|
+
"sort":sort,
|
|
1147
|
+
"target_profile_id": target_profile_id,
|
|
1148
|
+
},methode="getProfilePosts")['data']
|
|
1149
|
+
def get_info_Post(self,url_post:str,profile_id:str=None):
|
|
1150
|
+
return self._reuests_post(data={
|
|
1151
|
+
"share_string": url_post,
|
|
1152
|
+
"profile_id": profile_id,
|
|
1153
|
+
},methode="getPostByShareLink")['data']
|
|
1154
|
+
def search_HashTag(
|
|
1155
|
+
self,
|
|
1156
|
+
content: str,
|
|
1157
|
+
profile_id:str,
|
|
1158
|
+
limit: int = 20,
|
|
1159
|
+
) -> Dict[str, Any]:
|
|
1160
|
+
|
|
1161
|
+
payload = {
|
|
1162
|
+
"profile_id": profile_id,
|
|
1163
|
+
"content": content,
|
|
1164
|
+
"limit": limit
|
|
1165
|
+
}
|
|
1166
|
+
return self._reuests_post("reportProfile", data=payload)
|
|
1167
|
+
def accept_Follow_Request(
|
|
1168
|
+
self,
|
|
1169
|
+
request_id: str,
|
|
1170
|
+
profile_id: Optional[str] = None
|
|
1171
|
+
) -> Dict[str, Any]:
|
|
1172
|
+
"""
|
|
1173
|
+
Accept a follow request from a user.
|
|
1174
|
+
|
|
1175
|
+
Args:
|
|
1176
|
+
request_id (str): The ID of the follow request.
|
|
1177
|
+
profile_id (Optional[str]): The profile ID of the current user (if available).
|
|
1178
|
+
|
|
1179
|
+
Returns:
|
|
1180
|
+
Dict[str, Any]: The server's response, including action status.
|
|
1181
|
+
"""
|
|
1182
|
+
payload = {
|
|
1183
|
+
"action": "Accept",
|
|
1184
|
+
"request_id": request_id,
|
|
1185
|
+
"profile_id": profile_id
|
|
1186
|
+
}
|
|
1187
|
+
return self._reuests_post("actionOnRequest", data=payload)
|
|
1188
|
+
def decline_Follow_Request(
|
|
1189
|
+
self,
|
|
1190
|
+
request_id: str,
|
|
1191
|
+
profile_id: Optional[str] = None
|
|
1192
|
+
) -> Dict[str, Any]:
|
|
1193
|
+
"""
|
|
1194
|
+
Decline a follow request from a user.
|
|
1195
|
+
|
|
1196
|
+
Args:
|
|
1197
|
+
request_id (str): The ID of the follow request.
|
|
1198
|
+
profile_id (Optional[str]): The profile ID of the current user (if available).
|
|
1199
|
+
|
|
1200
|
+
Returns:
|
|
1201
|
+
Dict[str, Any]: The server's response, including action status.
|
|
1202
|
+
"""
|
|
1203
|
+
payload = {
|
|
1204
|
+
"action": "Decline",
|
|
1205
|
+
"request_id": request_id,
|
|
1206
|
+
"profile_id": profile_id
|
|
1207
|
+
}
|
|
1208
|
+
return self._reuests_post("actionOnRequest", data=payload)
|
|
1209
|
+
def get_New_Follow_Requests(
|
|
1210
|
+
self,
|
|
1211
|
+
profile_id: Optional[str] = None ,
|
|
1212
|
+
limit: int = 20,
|
|
1213
|
+
sort: str = "FromMax"
|
|
1214
|
+
) -> Dict[str, Any]:
|
|
1215
|
+
"""
|
|
1216
|
+
Retrieve new follow requests for a given profile.
|
|
1217
|
+
|
|
1218
|
+
Args:
|
|
1219
|
+
profile_id (str): The profile ID of the current user.
|
|
1220
|
+
limit (int): The number of requests to fetch. Default is 20.
|
|
1221
|
+
sort (str): The sorting order for the requests. Default is "FromMax".
|
|
1222
|
+
|
|
1223
|
+
Returns:
|
|
1224
|
+
Dict[str, Any]: The server's response containing new follow requests.
|
|
1225
|
+
"""
|
|
1226
|
+
payload = {
|
|
1227
|
+
"profile_id": profile_id,
|
|
1228
|
+
"limit": limit,
|
|
1229
|
+
"sort": sort
|
|
1230
|
+
}
|
|
1231
|
+
return self._reuests_post("getNewFollowRequests", data=payload)
|