Esempio n. 1
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     if menuItemID != 0: return
     if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL:
         if schid in self.targets: self.stop("", schid, self.targets[schid])
         else:
             ts3lib.printMessageToCurrentTab(
                 "{} {}: [color=red]Not following anyone on this tab.[/color]"
                 .format(timestamp(), self.name))
             uid = inputBox(self.name, "UID:",
                            QApplication.clipboard().text())
             parsed = parseClientURL(uid)
             if parsed: uid = parsed[1]
     elif atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT:
         (err, ownID) = ts3lib.getClientID(schid)
         if selectedItemID == ownID: return
         (err, uid) = ts3lib.getClientVariable(
             schid, selectedItemID,
             ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
         if not uid:
             ts3lib.printMessageToCurrentTab(
                 "{} {}: [color=red]Cannot follow[/color] {}".format(
                     timestamp(), self.name, selectedItemID))
             return
         self.targets[schid] = uid
         ts3lib.printMessageToCurrentTab(
             "{} {}: [color=green]Now auto-following[/color] {}".format(
                 timestamp(), self.name, clientURL(schid, selectedItemID)))
         if PluginHost.cfg.getboolean("general", "verbose"):
             print(self.name, "> self.targets[schid]", self.targets[schid],
                   "selectedItemID", selectedItemID)
         self.joinTarget(schid)
Esempio n. 2
0
 def getText(self,
             multimsg=True,
             multiline=False,
             title="Enter text here",
             text="",
             max=1024):
     try:
         x = QDialog()
         x.setAttribute(Qt.WA_DeleteOnClose)
         if multiline:
             clipboard = QApplication.clipboard().text()
             _message = QInputDialog.getMultiLineText(
                 x, title, text, clipboard)
         else:
             _message = QInputDialog.getText(x, title, text,
                                             QLineEdit.Normal, "", self.ok)
         if multimsg:
             return [
                 _message[i:i + max] for i in range(0, len(_message), max)
             ]
         else:
             return _message[:max]
     except:
         from traceback import format_exc
         ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR,
                           "pyTSon", 0)
Esempio n. 3
0
 def disconnect(self, schid=0, close_tab=False):
     if schid < 1: schid = ts3lib.getCurrentServerConnectionHandlerID()
     (err, status) = ts3lib.getConnectionStatus(schid)
     if status != ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED:
         return
     clipboard = QApplication.clipboard().text()
     msg = inputBox("Disconnect", "Message", clipboard)
     if close_tab: self.schid = schid
     ts3lib.stopConnection(schid, msg if msg else "")
Esempio n. 4
0
 def onMenuItemEvent(self, schid, atype, menuItemID, channel):
     if menuItemID == 0:
         err, cids = ts3lib.getChannelList(schid)
         channels = dict()
         for cid in cids:
             (err, name) = ts3lib.getChannelVariable(
                 schid, cid, ts3defines.ChannelProperties.CHANNEL_NAME)
             (err, order) = ts3lib.getChannelVariable(
                 schid, cid, ts3defines.ChannelProperties.CHANNEL_ORDER)
             if err == ts3defines.ERROR_ok and name: channels[order] = name
         channels = OrderedDict(sorted(channels.items(),
                                       key=lambda t: t[0]))
         for name in channels.values():
             ts3lib.printMessageToCurrentTab(name)
     elif menuItemID == 1:
         description = ts3lib.getChannelVariableAsString(
             schid, channel,
             ts3defines.ChannelProperties.CHANNEL_DESCRIPTION)[1]
         ts3lib.printMessageToCurrentTab(description)
         QApplication.clipboard().setText(description)
Esempio n. 5
0
 def sendMessage(self, schid, targetMode, toID):
     x = QWidget()
     clipboard = QApplication.clipboard().text();
     _message = QInputDialog.getMultiLineText(x, "Enter long text here", "", clipboard)
     message = [_message[i:i + self.maxsize] for i in range(0, len(_message), self.maxsize)]
     if targetMode == ts3defines.TextMessageTargetMode.TextMessageTarget_CHANNEL:
         for msg in message:
             error = ts3lib.requestSendChannelTextMsg(schid, "\n"+msg, toID)
             if not error == ts3defines.ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error #%s"%error,"Unable to send message to #%s!"%toID);_t.show();return
     elif targetMode == ts3defines.TextMessageTargetMode.TextMessageTarget_CLIENT:
         for msg in message:
             error = ts3lib.requestSendPrivateTextMsg(schid, "\n"+msg, toID)
             if not error == ts3defines.ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error #%s"%error,"Unable to send message to #%s!"%toID);_t.show();return
Esempio n. 6
0
def inputBox(title, text, default=""):
    """
    :param default:
    :param title:
    :param text:
    :return:
    """
    x = QWidget()
    x.setAttribute(Qt.WA_DeleteOnClose)
    ok = BoolResult()
    if not default: default = QApplication.clipboard().text()
    text = QInputDialog.getText(x, title, text, QLineEdit.Normal, default, ok) # QDir.Home.dirName()
    if ok: return text
    else: return False
Esempio n. 7
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     try:
         url = ""
         if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT:
             if menuItemID == 1:  # Nickname (TSViewer)
                 url = "http://www.tsviewer.com/index.php?page=search&action=ausgabe_user&nickname=%%CLIENT_NAME_PERCENT_ENCODED%%"
             elif menuItemID == 2:  # Nickname (GameTracker)
                 url = "http://www.gametracker.com/search/?search_by=online_offline_player&query=%%CLIENT_NAME_PERCENT_ENCODED%%"
             elif menuItemID == 3:  # Nickname (TS3Index)
                 url = "http://ts3index.com/?page=searchclient&nickname=%%CLIENT_NAME_PERCENT_ENCODED%%"
             elif menuItemID == 4:  # Nickname (Google)
                 url = "https://www.google.com/search?q=%%CLIENT_NAME_PERCENT_ENCODED%%"
             elif menuItemID == 5:  # Profil (GameTracker)
                 url = "http://www.gametracker.com/search/?search_by=profile_username&query=%%CLIENT_NAME_PERCENT_ENCODED%%"
             elif menuItemID == 6:  # UID (TS3Index)
                 url = "http://ts3index.com/?page=searchclient&uid=%%CLIENT_UNIQUE_ID%%"
             elif menuItemID == 7:  # UID (Google)
                 url = "https://www.google.com/search?q=%%CLIENT_UNIQUE_ID%%"
             elif menuItemID == 8:  # Besitzer (TSViewer)
                 url = "http://www.tsviewer.com/index.php?page=search&action=ausgabe&suchbereich=ansprechpartner&suchinhalt=%%CLIENT_NAME_PERCENT_ENCODED%%"
             elif menuItemID == 9:  # Badges (TS3Index)
                 url = "https://ts3index.com/?page=searchclient&badges=%%CLIENT_BADGES%%"
             else:
                 return
             # payload = {'username':'******', 'password':'******'}
             # nickname_encoded = urlencode(nickname, quote_via=quote_plus)
             # nickname_encoded = nickname_encoded.replace("+", "%2B").replace("/", "%2F").replace("=", "%3D")
             if "%%CLIENT_NAME_PERCENT_ENCODED%%" in url:
                 if selectedItemID:
                     (err, nickname) = ts3lib.getClientVariable(
                         schid, selectedItemID,
                         ts3defines.ClientProperties.CLIENT_NICKNAME)
                 else:
                     nickname = inputBox(self.name, "Nickname:",
                                         QApplication.clipboard().text())
                 parsed = parseClientURL(nickname)
                 if parsed: nickname = parsed[2]
                 else: nickname = QUrl.toPercentEncoding(nickname)
                 url = url.replace("%%CLIENT_NAME_PERCENT_ENCODED%%",
                                   "{}".format(nickname))
             if "%%CLIENT_UNIQUE_ID%%" in url:
                 if selectedItemID:
                     (err, uid) = ts3lib.getClientVariable(
                         schid, selectedItemID, ts3defines.ClientProperties.
                         CLIENT_UNIQUE_IDENTIFIER)
                 else:
                     uid = inputBox(self.name, "UID:",
                                    QApplication.clipboard().text())
                 parsed = parseClientURL(uid)
                 if parsed: uid = parsed[1]
                 url = url.replace("%%CLIENT_UNIQUE_ID%%",
                                   "{}".format(QUrl.toPercentEncoding(uid)))
             if "%%CLIENT_BADGES%%" in url:
                 if selectedItemID:
                     (err, badges) = ts3lib.getClientVariable(
                         schid, selectedItemID,
                         ts3defines.ClientPropertiesRare.CLIENT_BADGES)
                 else:
                     badges = inputBox(self.name, "Badges:",
                                       QApplication.clipboard().text())
                 url = url.replace("%%CLIENT_BADGES%%", badges)
         else:
             return
         if PluginHost.cfg.getboolean("general", "verbose"):
             ts3lib.printMessageToCurrentTab(
                 "Opening URL: \"{}\"".format(url))
         QDesktopServices.openUrl(QUrl(url))
     except:
         ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR,
                           "pyTSon", 0)