PySPlus 0.1__tar.gz → 0.3__tar.gz
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.
- {pysplus-0.1 → pysplus-0.3}/PKG-INFO +5 -3
- {pysplus-0.1 → pysplus-0.3}/PySPlus.egg-info/PKG-INFO +5 -3
- {pysplus-0.1 → pysplus-0.3}/PySPlus.egg-info/SOURCES.txt +1 -2
- {pysplus-0.1 → pysplus-0.3}/PySPlus.egg-info/requires.txt +1 -0
- {pysplus-0.1 → pysplus-0.3}/README.md +2 -1
- {pysplus-0.1 → pysplus-0.3}/pysplus/Client.py +54 -5
- {pysplus-0.1 → pysplus-0.3}/setup.py +3 -3
- pysplus-0.1/pysplus/test.py +0 -8
- {pysplus-0.1 → pysplus-0.3}/PySPlus.egg-info/dependency_links.txt +0 -0
- {pysplus-0.1 → pysplus-0.3}/PySPlus.egg-info/top_level.txt +0 -0
- {pysplus-0.1 → pysplus-0.3}/pysplus/__init__.py +0 -0
- {pysplus-0.1 → pysplus-0.3}/pysplus/colors.py +0 -0
- {pysplus-0.1 → pysplus-0.3}/setup.cfg +0 -0
@@ -1,8 +1,8 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: PySPlus
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.3
|
4
4
|
Summary: the library SPlus platform for bots.
|
5
|
-
Home-page: https://github.com/OandONE/
|
5
|
+
Home-page: https://github.com/OandONE/SPlus
|
6
6
|
Author: seyyed mohamad hosein moosavi raja(01)
|
7
7
|
Author-email: mohamadhosein159159@gmail.com
|
8
8
|
License: MIT
|
@@ -10,6 +10,7 @@ Requires-Python: >=3.8
|
|
10
10
|
Description-Content-Type: text/markdown
|
11
11
|
Requires-Dist: selenium==4.29.0
|
12
12
|
Requires-Dist: webdriver_manager==4.0.2
|
13
|
+
Requires-Dist: bs4==0.0.2
|
13
14
|
Dynamic: author
|
14
15
|
Dynamic: author-email
|
15
16
|
Dynamic: description
|
@@ -33,4 +34,5 @@ This Python library is for SPlus platform bots and is currently being updated.
|
|
33
34
|
## install :
|
34
35
|
|
35
36
|
```bash
|
36
|
-
pip install
|
37
|
+
pip install --upgrade PySPlus
|
38
|
+
```
|
@@ -1,8 +1,8 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: PySPlus
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.3
|
4
4
|
Summary: the library SPlus platform for bots.
|
5
|
-
Home-page: https://github.com/OandONE/
|
5
|
+
Home-page: https://github.com/OandONE/SPlus
|
6
6
|
Author: seyyed mohamad hosein moosavi raja(01)
|
7
7
|
Author-email: mohamadhosein159159@gmail.com
|
8
8
|
License: MIT
|
@@ -10,6 +10,7 @@ Requires-Python: >=3.8
|
|
10
10
|
Description-Content-Type: text/markdown
|
11
11
|
Requires-Dist: selenium==4.29.0
|
12
12
|
Requires-Dist: webdriver_manager==4.0.2
|
13
|
+
Requires-Dist: bs4==0.0.2
|
13
14
|
Dynamic: author
|
14
15
|
Dynamic: author-email
|
15
16
|
Dynamic: description
|
@@ -33,4 +34,5 @@ This Python library is for SPlus platform bots and is currently being updated.
|
|
33
34
|
## install :
|
34
35
|
|
35
36
|
```bash
|
36
|
-
pip install
|
37
|
+
pip install --upgrade PySPlus
|
38
|
+
```
|
@@ -5,6 +5,7 @@ from selenium.webdriver.support import expected_conditions as EC
|
|
5
5
|
from selenium.webdriver.chrome.service import Service
|
6
6
|
from selenium.webdriver.chrome.options import Options
|
7
7
|
from webdriver_manager.chrome import ChromeDriverManager
|
8
|
+
from bs4 import BeautifulSoup
|
8
9
|
from .colors import *
|
9
10
|
from typing import Optional
|
10
11
|
import time,os,json,asyncio,logging,pickle
|
@@ -76,14 +77,17 @@ class Client:
|
|
76
77
|
if not number.startswith("9"):
|
77
78
|
return False
|
78
79
|
return True
|
79
|
-
async def login(self):
|
80
|
+
async def login(self) -> bool:
|
81
|
+
"""لاگین / login"""
|
80
82
|
chrome_options = Options()
|
83
|
+
chrome_options.add_argument("--headless")
|
81
84
|
chrome_options.add_argument("--start-maximized")
|
82
85
|
chrome_options.add_argument("--disable-notifications")
|
83
86
|
chrome_options.add_argument("--lang=fa")
|
84
87
|
chrome_options.add_experimental_option("detach", True)
|
85
88
|
service = Service(ChromeDriverManager().install())
|
86
89
|
driver = webdriver.Chrome(service=service, options=chrome_options)
|
90
|
+
self.driver = webdriver.Chrome(service=service, options=chrome_options)
|
87
91
|
wait = WebDriverWait(driver, 15)
|
88
92
|
try:
|
89
93
|
driver.get("https://web.splus.ir")
|
@@ -120,17 +124,62 @@ class Client:
|
|
120
124
|
code_input = wait.until(
|
121
125
|
EC.presence_of_element_located((By.CSS_SELECTOR, "input#sign-in-code"))
|
122
126
|
)
|
127
|
+
self.code_html = driver.page_source
|
123
128
|
code_input.clear()
|
124
129
|
code_input.send_keys(verification_code)
|
125
|
-
verify_button = wait.until(
|
126
|
-
EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), 'تأیید') or contains(text(), 'Verify')]"))
|
127
|
-
)
|
128
|
-
verify_button.click()
|
129
130
|
time.sleep(5)
|
131
|
+
self.code_html = driver.page_source
|
132
|
+
messages = await self.get_chat_ids()
|
133
|
+
while not messages:
|
134
|
+
time.sleep(1)
|
135
|
+
self.code_html = driver.page_source
|
136
|
+
messages = await self.get_chat_ids()
|
130
137
|
with open(self.name_cookies, 'wb') as file:
|
131
138
|
pickle.dump(driver.get_cookies(), file)
|
132
139
|
return True
|
133
140
|
except Exception as e:
|
134
141
|
driver.save_screenshot("error_screenshot.png")
|
142
|
+
print("ERROR :")
|
135
143
|
print(e)
|
144
|
+
print("ERROR SAVED : error_screenshot.png")
|
145
|
+
return False
|
146
|
+
async def get_chat_ids(self) -> list:
|
147
|
+
"""گرفتن چت آیدی ها / getting chat ids"""
|
148
|
+
soup = BeautifulSoup(self.code_html, "html.parser")
|
149
|
+
root = soup.select_one(
|
150
|
+
"body > #UiLoader > div.Transition.full-height > "
|
151
|
+
"#Main.left-column-shown.left-column-open > "
|
152
|
+
"#LeftColumn > #LeftColumn-main > div.Transition > "
|
153
|
+
"div.ChatFolders.not-open.not-shown > div.Transition > "
|
154
|
+
"div.chat-list.custom-scroll > div[style*='position: relative']"
|
155
|
+
)
|
156
|
+
chats = []
|
157
|
+
if root:
|
158
|
+
divs = root.find_all("div", recursive=True)
|
159
|
+
for div in divs:
|
160
|
+
anchors = div.find_all("a", href=True)
|
161
|
+
for a in anchors:
|
162
|
+
if a!=None:
|
163
|
+
chat = str(a["href"]).replace("#","")
|
164
|
+
chats.append(chat)
|
165
|
+
else:
|
166
|
+
print("❌ تگ ریشه پیدا نشد!")
|
167
|
+
return chats
|
168
|
+
async def send_text(self,chat_id:str,text:str) -> bool:
|
169
|
+
"""ارسال متن / sending text"""
|
170
|
+
try:
|
171
|
+
self.driver.get(f"https://web.splus.ir/#{chat_id}")
|
172
|
+
time.sleep(3)
|
173
|
+
input_box = WebDriverWait(self.driver, 15).until(
|
174
|
+
EC.presence_of_element_located((By.CSS_SELECTOR, "div.input-message-input"))
|
175
|
+
)
|
176
|
+
input_box.click()
|
177
|
+
input_box.send_keys(text)
|
178
|
+
send_button = WebDriverWait(self.driver, 15).until(
|
179
|
+
EC.element_to_be_clickable((By.CSS_SELECTOR, "button.Button.send"))
|
180
|
+
)
|
181
|
+
send_button.click()
|
182
|
+
return True
|
183
|
+
except Exception as e:
|
184
|
+
print("Error in send_text:", e)
|
136
185
|
return False
|
@@ -2,15 +2,15 @@ from setuptools import setup, find_packages
|
|
2
2
|
|
3
3
|
setup(
|
4
4
|
name="PySPlus",
|
5
|
-
version="0.
|
5
|
+
version="0.3",
|
6
6
|
author="seyyed mohamad hosein moosavi raja(01)",
|
7
7
|
author_email="mohamadhosein159159@gmail.com",
|
8
8
|
description="the library SPlus platform for bots.",
|
9
9
|
long_description=open("README.md").read(),
|
10
10
|
long_description_content_type="text/markdown",
|
11
|
-
url="https://github.com/OandONE/
|
11
|
+
url="https://github.com/OandONE/SPlus",
|
12
12
|
packages=find_packages(),
|
13
13
|
python_requires='>=3.8',
|
14
|
-
install_requires=["selenium==4.29.0","webdriver_manager==4.0.2"],
|
14
|
+
install_requires=["selenium==4.29.0","webdriver_manager==4.0.2","bs4==0.0.2"],
|
15
15
|
license="MIT"
|
16
16
|
)
|
pysplus-0.1/pysplus/test.py
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|