Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
correções ortografica
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasCaetanoSz committed Dec 16, 2023
1 parent 6dac34f commit d340394
Show file tree
Hide file tree
Showing 8 changed files with 363 additions and 364 deletions.
62 changes: 35 additions & 27 deletions accounts.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
from PyQt5.QtWidgets import QMainWindow, QPushButton, QVBoxLayout, QWidget, QHBoxLayout, QStackedWidget, QScrollArea, QInputDialog, QMessageBox
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineProfile, QWebEnginePage
from PyQt5.QtWebEngineCore import QWebEngineUrlRequestInterceptor
from PyQt5.QtGui import QIcon, QCursor
from PyQt5.QtCore import QUrl, Qt
from PyQt5.QtWidgets import (
QStackedWidget,
QMainWindow,
QPushButton,
QVBoxLayout,
QInputDialog,
QHBoxLayout,
QScrollArea,
QMessageBox,
QWidget
)

from PyQt5.QtWebEngineWidgets import (QWebEngineView, QWebEngineProfile, QWebEnginePage)
from PyQt5.QtWebEngineCore import (QWebEngineUrlRequestInterceptor)
from PyQt5.QtGui import (QIcon, QCursor)
from PyQt5.QtCore import (QUrl, Qt)

import shutil
import json
import os

SINGNALS = None
SIGNALS = None

# sobresve as funço
# es de log do QWebEnginePage para que as saidas geradas sejam escritas
# um aquivo de log. é assim que o programa cosegue executar sem precisar de stdout
# sobrescreve as funções de log javascript para que, todas as saídas geradas sejam escritas no arquivo de log do maturador

class LogCapturingPage(QWebEnginePage):
def consoleMessage(self, level, message, lineNumber, sourceID):
Expand All @@ -32,9 +41,10 @@ def javaScriptConsoleMessage(self, level, message, lineNumber, sourceID):
pass


# intercptar as request para conseguir encontrar as que é feita para o programa
# isso é nescesario pois o whatssap web bloqueia requisições feitas para dominios
# diferente do deles atráves do content security policy (CSP).
# interceptar as requisições que vem do WhatsApp web para filtrar
# as que são feitas para enviar dados ao maturador, isso é necessário
# pois o WhatsApp web bloqueia requisições feitas para domínios
# diferente do deles através do content security policy (CSP).

class RequestInterceptor(QWebEngineUrlRequestInterceptor):
def interceptRequest(self, info):
Expand All @@ -45,8 +55,8 @@ def interceptRequest(self, info):
url_path = info.requestUrl().path()
json_string = url_path[url_path.find("{"):url_path.find("}") + 1]
data = json.loads(json_string)
global SINGNALS
SINGNALS.new_phone_number.emit(data)
global SIGNALS
SIGNALS.new_phone_number.emit(data)
info.block(True)

# conta bloqueada
Expand All @@ -55,14 +65,14 @@ def interceptRequest(self, info):
url_path = info.requestUrl().path()
json_string = url_path[url_path.find("{"):url_path.find("}") + 1]
data = json.loads(json_string)
SINGNALS.account_blocked.emit(data)
SIGNALS.account_blocked.emit(data)
info.block(True)


class MainWindow(QMainWindow):
def __init__(self):
self.controller = None
self._opened = False
self._is_open = False
super().__init__()
self.webs_engine = []
self.setWindowTitle("Maturador de chips - Contas conectadas")
Expand All @@ -85,7 +95,7 @@ def __init__(self):
self.buttons_widget = QWidget()
self.buttons_widget.setFixedHeight(50)

# configura o layout dos botoes de altenar entre instancias
# configura o layout dos botoes de alternar entre instancias

buttons_scroll_area = QScrollArea()
buttons_scroll_area.setWidgetResizable(True)
Expand All @@ -112,7 +122,7 @@ def __init__(self):

main_layout.addWidget(self.stacked_widget)

# botões "adicionar" e "remove" layout
# botões "adicionar" e "remover" layout

buttons_container = QWidget()
buttons_container.setLayout(main_layout)
Expand All @@ -122,7 +132,7 @@ def __init__(self):
remove_instance_button = QPushButton("Remover")
remove_instance_button.clicked.connect(self.delete_session)

# personaliza os dois botões (add e rem)
# personaliza os dois botões "adicionar" e "remover"

add_instance_button.setCursor(QCursor(Qt.PointingHandCursor))
remove_instance_button.setCursor(QCursor(Qt.PointingHandCursor))
Expand Down Expand Up @@ -163,14 +173,14 @@ def __init__(self):
button_layout.addWidget(remove_instance_button)
buttons_container.layout().addLayout(button_layout)

# configurar o wiget central da janela
# configurar o widget central da janela

central_widget = QWidget()
central_widget.setLayout(main_layout)
self.setCentralWidget(central_widget)

def closeEvent(self, event):
self._opened = False
self._is_open = False
event.accept()

# criar nova sessão/webview
Expand All @@ -187,10 +197,10 @@ def create_session(self):
QMessageBox.critical(self, "Maturador de chips","o nome da instância não pode estar vazio")

elif len(session_name) > 11:
QMessageBox.critical(self, "Maturador de chips","o nome da instância não pode ter mais de 11 digitos")
QMessageBox.critical(self, "Maturador de chips","o nome da instância não pode ter mais de 11 dígitos")

elif os.path.exists(os.path.join("sessions", f"@{session_name}")):
QMessageBox.critical(self, "Maturador de chips", f"já existe uma instância com o nome {session_name}, escolha outro nome.")
QMessageBox.critical(self, "Maturador de chips", f"já existe uma instância com o nome {session_name}, escolha outro.")

else:
session_name = "@" + session_name
Expand All @@ -211,7 +221,6 @@ def create_session(self):
webview.setPage(engine)
self.webs_engine.append(engine)
webview.load(QUrl("https://web.whatsapp.com/"))
#webview.load(QUrl("https://example.com/"))
self.stacked_widget.addWidget(webview)
self.webviews.append(webview)
self.create_button(session_name).click()
Expand Down Expand Up @@ -248,7 +257,6 @@ def load_webviews(self):
webview.setPage(engine)
self.webs_engine.append(engine)
webview.load(QUrl("https://web.whatsapp.com/"))
#webview.load(QUrl("https://example.com/"))
self.create_button(sessionname)
self.webviews.append(webview)
webview.page().loadFinished.connect(lambda ok, session_name=sessionname : self.run_script(session_name))
Expand Down Expand Up @@ -345,7 +353,7 @@ def highlight_current_button(self, idx):

def delete_session(self):
if not self.selected_button:
return QMessageBox.critical(self, "Maturador de chips","nenhuma instância aberta, impossivel apagar.")
return QMessageBox.critical(self, "Maturador de chips","nenhuma instância aberta, impossível apagar.")

confirm = QMessageBox.question(
self,
Expand Down Expand Up @@ -379,7 +387,7 @@ def delete_session(self):
)
try:
self.controller.connected_numbers.pop(key)
SINGNALS.new_phone_number.emit({})
SIGNALS.new_phone_number.emit({})
except KeyError:
pass
break
Expand Down
54 changes: 29 additions & 25 deletions controller.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
from PyQt5.QtCore import pyqtSlot, QObject
from tkinter import filedialog, messagebox
from PyQt5.QtWidgets import QMessageBox
from tkinter import filedialog
import webbrowser
import json
import os

class Controller(QObject):
def __init__(self, accounts_page, version, signals):
super().__init__()
self.siginals = signals
self.signals = signals
self.accounts_page_instance = accounts_page
self.messages_base = {"content":[], "filename":"Selecionar arquivo"}
self.VERSION = version
self.configs:dict = json.loads((open(file="state.json", mode="r", encoding="utf8").read()))
self.connected_numbers = {}

# bot de numeros virtuais no telegram
# bot de números virtuais no telegram

@pyqtSlot()
def telegram_bot_virtual_number_open(self):
def telegram_virtual_number_bot_open(self):
try:
if os.path.exists(
os.path.join(
Expand All @@ -36,34 +37,34 @@ def telegram_bot_virtual_number_open(self):
# exibir contas conectadas

@pyqtSlot()
def accounts_viewer(self):
if self.accounts_page_instance._opened:
self.accounts_page_instance.activateWindow()
self.accounts_page_instance._opened = True
def view_accounts(self):
if self.accounts_page_instance._is_open:
return self.accounts_page_instance.activateWindow()
self.accounts_page_instance._is_open = True
self.accounts_page_instance.show()

# relatar problema
# relatar problema no github

@pyqtSlot()
def open_insues_link(self):
def open_project_issues(self):
webbrowser.open(url="https://github.com/JonasCaetanoSz/maturador-de-chips/issues")

# abrir o link do repositório do projeto no github

@pyqtSlot()
def open_github_repository(self):
def open_project_repository(self):
webbrowser.open(url="https://github.com/JonasCaetanoSz/maturador-de-chips")

# abrir o link da licença do código

@pyqtSlot()
def open_license_repository(self):
def open_project_license(self):
webbrowser.open(url="https://github.com/JonasCaetanoSz/maturador-de-chips/blob/main/LICENSE")

# selecionar o arquivo de conversas

@pyqtSlot(result=str)
def selected_file(self):
def select_file(self):
file_path = filedialog.askopenfilename(
filetypes=[("Arquivos de Texto", "*.txt"),],
title="Maturador de Chips - selecione o arquivo de mensagens base")
Expand All @@ -82,34 +83,37 @@ def selected_file(self):
# mostrar versão do projeto

@pyqtSlot()
def view_version_project(self):
messagebox.showinfo(
"Maturador de chips",
f"você está usando a versão {self.VERSION}, verifique a qualquer momento no github se há atualizações disponiveis."
def view_project_version(self):
QMessageBox.about(
self.accounts_page_instance,
"Maturador de Chips",
f"você está usando a versão {self.VERSION}, verifique a qualquer momento no github se há atualizações disponíveis."
)

# mostrar pagina do disparador

@pyqtSlot()
def disparador(self):
messagebox.showinfo(
"Maturador de chips",
f"este recurso estará disponivel na proxima atualização!"
QMessageBox.about(
self.accounts_page_instance,
"Maturador de Chips",
"este recurso estará disponível na proxima atualização!"
)

# obter as configurações do usuario

# obter as configurações do usuário

@pyqtSlot(result=str)

def user_configs(self) -> str:
def get_user_configs(self) -> str:
configs = self.configs.copy()
configs.update({
"filename": self.messages_base["filename"],
"accounts": self.connected_numbers.copy()
})
return json.dumps(configs)

# atualizar as configurações do usuario
# atualizar as configurações do usuário

@pyqtSlot(str, result=str)
def update_user_configs(self, new_configs:str):
Expand Down Expand Up @@ -140,10 +144,10 @@ def account_blocked(self, account_data):

@pyqtSlot(result=str)
def start_maturation(self):
self.siginals.start_maturation.emit(self.messages_base, self.connected_numbers)
self.signals.start_maturation.emit(self.messages_base, self.connected_numbers)

# parar a maturação

@pyqtSlot(result=str)
def stop_maturation(self):
self.siginals.stop_maturation.emit()
self.signals.stop_maturation.emit()
16 changes: 11 additions & 5 deletions dashboard.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
import typing
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineProfile , QWebEnginePage
from PyQt5.QtWebChannel import QWebChannel
from PyQt5.QtCore import QUrl, QSettings
from PyQt5.QtWidgets import QMainWindow
from controller import Controller
from PyQt5.QtGui import QIcon
from PyQt5 import QtWidgets

from controller import Controller
import shutil
import os

class Webview(QWebEngineView):
def __init__(self, parent: QtWidgets.QWidget | None = ...) -> None:
self.controller_channel:QWebChannel = None
super().__init__(parent)

def reload(self) -> None:
self.page().setWebChannel(self.controller_channel)
return super().reload()

# sobresve as funçoes de log do QWebEnginePage para que as saidas geradas sejam escritas
# um aquivo de log. é assim que o programa cosegue executar sem precisar de stdout
# sobrescreve as funções de log javascript do QWebEnginePage para que as saídas geradas ignoradas
# é assim que o programa consegue executar sem precisar de stdout do terminal

class LogCapturingPage(QWebEnginePage):
def consoleMessage(self, level, message, lineNumber, sourceID):
pass
def javaScriptConsoleMessage(self, level, message, lineNumber, sourceID):
pass


class MainWindow(QMainWindow):
def __init__(self, accounts_page, signals, app, controller:Controller):
Expand Down Expand Up @@ -48,9 +54,9 @@ def __init__(self, accounts_page, signals, app, controller:Controller):
engine = LogCapturingPage(profile, self.webview)
channel = QWebChannel(engine)
channel.registerObject("controller",controller)
self.webview.controller_channel = channel
engine.setWebChannel(channel)
self.webview.setPage(engine)
#self.webview.load(QUrl("https://site112.com/editor-online-html"))
self.webview.load(QUrl.fromLocalFile("/pages/dashboard.html"))
self.webview.page().action(QWebEnginePage.Back).setVisible(False)
self.webview.page().action(QWebEnginePage.Reload).setVisible(False)
Expand Down
Loading

0 comments on commit d340394

Please sign in to comment.