def _handle_server(self, prefix, cmd, suffix, params, caller): if cmd == "cmd": self.serv.executor.execute(suffix, params.split(' '), PluginUser(caller)) return True if cmd == "table": # https://github.com/stasivs/Messenger/issues/4 self.serv.resend( Bcast(""" <table> <tbody> <tr> <td>1</td> <td>2</td> </td> <tr> <td>3</td> <td>4</td> </td> </tbody> </table> """)) return True if cmd == "stop": sys.exit() return True if cmd == "say": if not prefix: self.serv.resend(Messages.Bcast(params)) else: self.serv.resend(UserMessage(params, prefix)) return True if cmd == "tell": if not suffix: return False user = self.serv.get_user_by_nick(suffix) if not prefix: user.send(Messages.Info(params)) else: user.send(UserMessage(params, prefix)) return True if cmd == "eval": res = eval(params) self.serv.resend(Messages.Info(res)) return True if cmd == "exec": exec(params) return True return False
def get_message(self): return Messages.Info(self.text)
import sys import pickle from PyQt5.QtWidgets import QApplication, QMainWindow from PyQt5.QtCore import Qt from UI import Ui_MainWindow import Messages import threading import socket wrongAddr = Messages.Error("Wrong server address!") failedServer = Messages.Error("Failed connect to server!") notConnected = Messages.Error("You have not connected!") youDisconnected = Messages.Info("You disconnected from server!") alreadyConnected = Messages.Error("You already connected") class MyWidget(QMainWindow, Ui_MainWindow): def __init__(self): super().__init__() self.setupUi(self) self.main() self.th = None self.sock = None self.connected = False def main(self): self.pushMessage.clicked.connect(self.sendMessage) self.IPConnection.clicked.connect(self.connect) self.Disconnect.clicked.connect(self.disconnect) def showMessage(self, message):