class spacify(ts3plugin): path = getScriptPath(__name__) name = "Spacify" try: apiVersion = pytson.getCurrentApiVersion() except: apiVersion = 22 requestAutoload = False version = "1.0" author = "Bluscream" description = "" offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [] hotkeys = [] widget = None last = "" # ignore = False def __init__(self): self.widget = widget("ChatLineEdit") result = self.widget.connect("textChanged()", self.textEdited) print("Result", result) if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab("{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded.".format(timestamp(),self.name,self.author)) def stop(self): self.widget.disconnect("textChanged()", self.textEdited) def textEdited(self): text = self.widget.toPlainText() if not text.endswith(" "): self.widget.insert(" ") # self.widget.cursorPosition(len(text)+1) # self.ignore = True self.last = self.widget.toPlainText()
class pluginEnabler(ts3plugin): name = "Plugin Enabler" try: apiVersion = getCurrentApiVersion() except: apiVersion = 22 requestAutoload = True version = "1.0" author = "Bluscream" description = "" offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [] hotkeys = [] def __init__(self): self.path = ts3lib.getPluginPath() if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab( "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded." .format(timestamp(), self.name, self.author)) def menuCreated(self): self.enableAll() def enableAll(self): for filename in listdir(self.path): if not filename.lower().endswith(".off"): continue pathname = path.join(self.path, filename) newname = filename.replace(".off", "", 1).replace(".OFF", "", 1) rename(pathname, path.join(path.dirname(pathname), newname))
class teaspeak(ts3plugin): name = "TeaSpeak" try: apiVersion = getCurrentApiVersion() except: apiVersion = 22 requestAutoload = False version = "1.0" author = "Bluscream" description = "TeaSpeak implementation" offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [ (ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "List Musicbots", "scripts/%s/teaspeak.png"%__name__), (ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL, 0, "List Musicbots", "scripts/%s/teaspeak.png"%__name__) ] hotkeys = [] def __init__(self): ts3lib.printMessageToCurrentTab("{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded.".format(timestamp(), self.name, self.author)) def menuCreated(self): self.checkMenus() def currentServerConnectionChanged(self, schid): self.checkMenus(schid) def checkMenus(self, schid=0): if not self.name in PluginHost.active: return if schid < 1: schid = ts3lib.getCurrentServerConnectionHandlerID() err, status = ts3lib.getConnectionStatus(schid) if status != ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED: return (err, suid) = ts3lib.getServerVariable(schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER) if suid != self.suid: self.toggleMenus(False) else: self.toggleMenus(True) def toggleMenus(self, enabled): for menuItem in self.menuItems: try: ts3lib.setPluginMenuEnabled(PluginHost.globalMenuID(self, menuItem[1]), enabled) except: pass
def start(cls): # start plugin if config says so, or if new plugin and # requestAutoload is True for key in cls.plugins: load = False if not cls.cfg.has_option("plugins", key): if cls.plugins[key].requestAutoload: load = True elif cls.cfg.getboolean("plugins", key, fallback=False): load = True if load: if (cls.plugins[key].apiVersion != pytson.getCurrentApiVersion()): if not cls.cfg.getboolean("general", "differentApi", fallback=False): continue cls.startPlugin(key) # restore reloaded menus for globid, (p, locid) in cls.menus.items(): if p in cls.active: cls.menus[globid] = (cls.active[p], locid) # restore reloaded hotkeys for keyword, (p, lockey) in cls.hotkeys.items(): if p in cls.active: cls.hotkeys[keyword] = (cls.active[p], lockey)
class friendNotifications(ts3plugin): name = "Friend Notifications" try: apiVersion = getCurrentApiVersion() except: apiVersion = 21 requestAutoload = False version = "0.1" author = "Bluscream" description = "" offersConfigure = False commandKeyword = "notify" infoTitle = "" menuItems = [] hotkeys = [] toaster = None # ToastNotifier() def __init__(self): if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab( "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded." .format(timestamp(), self.name, self.author)) def processCommand(self, schid, cmd): cmd = cmd.split(' ', 1) self.toaster.show_toast(cmd[0], cmd[1], icon_path=None, duration=5, threaded=True) return True
class queryConsole(ts3plugin): name = "TS3 Query Console" apiVersion = pytson.getCurrentApiVersion() requestAutoload = False version = "1.0" author = "Bluscream" description = "Adds a query console to your Teamspeak 3 Client.\n\nCheck out https://r4p3.net/forums/plugins.68/ for more plugins." offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "Show Query Console", "")] hotkeys = [] debug = False toggle = True dlg = None def __init__(self): ts3lib.logMessage( self.name + " script for pyTSon by " + self.author + " loaded from \"" + __file__ + "\".", ts3defines.LogLevel.LogLevel_INFO, "Python Script", 0) if self.debug: ts3lib.printMessageToCurrentTab( '[{:%Y-%m-%d %H:%M:%S}]'.format(datetime.now()) + " [color=orange]" + self.name + "[/color] Plugin for pyTSon by [url=https://github.com/" + self.author + "]" + self.author + "[/url] loaded.") def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if menuItemID == 0: if not self.dlg: self.dlg = QueryConsole() self.dlg.show() self.dlg.raise_() self.dlg.activateWindow()
class info(ts3plugin): name = "iconReplacer" apiVersion = pytson.getCurrentApiVersion() requestAutoload = True version = "1.0" author = "Exp" description = "Replaces the new (ugly) icon with the old one" offersConfigure = False commandKeyword = "" infoTitle = "Icon Replacer" menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "Replace Icon", "")] hotkeys = [] def __init__(self): self.dlg = None def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): try: if menuItemID == 0: pluginPath = pytson.getPluginPath("scripts", self.name) mainWindow = [ item for item in QApplication.instance().topLevelWidgets() if type(item).__name__ == "MainWindow" ][0] if not mainWindow: return mainWindow.setWindowIcon( QIcon(os.path.join(pluginPath, "small.ico"))) except: from traceback import format_exc ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
class report(ts3plugin): name = "Report" import pytson;apiVersion = pytson.getCurrentApiVersion() requestAutoload = False version = "1.0" author = "Bluscream" description = "Gives you the ability to quickly Report Users to Moderators.\n\nCheck out https://r4p3.net/forums/plugins.68/ for more plugins." offersConfigure = False commandKeyword = "" infoTitle = "" menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT, 0, "Add to Moderator", ""),(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT, 1, "Remove from Moderators", ""),(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT, 2, "Report User", "")] hotkeys = [] debug = False def __init__(self): ts3.printMessageToCurrentTab('[{:%Y-%m-%d %H:%M:%S}]'.format(datetime.datetime.now())+" [color=orange]"+self.name+"[/color] Plugin for pyTSon by [url=https://github.com/Bluscream]Bluscream[/url] loaded.") def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if menuItemID == 0: schid = ts3.getCurrentServerConnectionHandlerID() (error, item) = ts3.getClientDisplayName(schid, selectedItemID) ts3.printMessageToCurrentTab('[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.datetime.now())+" [color=green]Added[/color] [color=yellow]"+item+"[/color] to Report Moderators.") if menuItemID == 1: schid = ts3.getCurrentServerConnectionHandlerID() (error, item) = ts3.getClientDisplayName(schid, selectedItemID) ts3.printMessageToCurrentTab('[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.datetime.now())+" [color=red]Removed[/color] [color=yellow]"+item+"[/color] from Report Moderators.") if menuItemID == 2: self.dlg = ReportDialog(None) self.dlg.show()
def start(cls): # start plugin if config says so, or if new plugin and # requestAutoload is True for key in cls.plugins: load = False if not cls.cfg.has_option("plugins", key): if cls.plugins[key].requestAutoload: load = True elif cls.cfg.getboolean("plugins", key, fallback=False): load = True if load: if (cls.plugins[key].apiVersion != pytson.getCurrentApiVersion()): if not cls.cfg.getboolean( "general", "differentApi", fallback=False): continue cls.startPlugin(key) # restore reloaded menus for globid, (p, locid) in cls.menus.items(): if p in cls.active: cls.menus[globid] = (cls.active[p], locid) # restore reloaded hotkeys for keyword, (p, lockey) in cls.hotkeys.items(): if p in cls.active: cls.hotkeys[keyword] = (cls.active[p], lockey)
class avatarScanner(ts3plugin): name = "Scan Avatars" try: apiVersion = getCurrentApiVersion() except: apiVersion = 21 requestAutoload = False version = "1" author = "Bluscream" description = "Let's you scan the subscribed channels for users that have an avatar set" offersConfigure = False commandKeyword = "avatar" infoTitle = None menuItems = [] # [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, name, "")] hotkeys = [] def __init__(self): if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab("{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded.".format(timestamp(), self.name, self.author)) def processCommand(self, schid, command): self.printAvatarUsers(schid); return True def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL and menuItemID == 0: self.printAvatarUsers(schid) def printAvatarUsers(self, schid): (err, clist) = ts3lib.getClientList(schid) msg = [] for c in clist: (err, avatar) = ts3lib.getClientVariable(schid, c, ts3defines.ClientPropertiesRare.CLIENT_FLAG_AVATAR) if not avatar or avatar.strip() == "": continue msg.append("{}: {}".format(clientURL(schid, c), avatar)) ts3lib.printMessageToCurrentTab("{}[u]Online users with avatars[/u]: [b]{}[/b]".format(timestamp(), len(msg))) i = 1 for m in msg: ts3lib.printMessageToCurrentTab("{} {}".format(i, m)); i += 1
class purgeContacts(ts3plugin): name = "Purge Contacts" try: apiVersion = getCurrentApiVersion() except: apiVersion = 21 requestAutoload = True version = "1" author = "Bluscream" description = "Allows you to clean your contact list " offersConfigure = False commandKeyword = "" infoTitle = "" menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, name, "")] hotkeys = [] scriptpath = path.join(getPluginPath(), "scripts", "purgeContacts") dlg = None def __init__(self): if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab("{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded.".format(timestamp(), self.name, self.author)) def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype != ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL or menuItemID != 0: return self.dlg = calendarDialog(self) self.dlg.show() self.dlg.raise_() self.dlg.activateWindow()
class autoJoin(ts3plugin): path = getScriptPath(__name__) name = "Auto Join" try: apiVersion = getCurrentApiVersion() except: apiVersion = 21 requestAutoload = True version = "1.0" author = "Bluscream" description = "" offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, name, "")] hotkeys = [] schid = 0 request_tp = False def __init__(self): if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab("{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded.".format(timestamp(), self.name, self.author)) def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype != ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL or menuItemID != 0: return if schid == self.schid: self.schid = 0; ts3lib.printMessageToCurrentTab("{} > Disabled!".format(self.name)) else: self.schid = schid; ts3lib.printMessageToCurrentTab("{} > Enabled for tab #{}!".format(self.name,schid)) def onNewChannelCreatedEvent(self, schid, cid, channelParentID, invokerID, invokerName, invokerUniqueIdentifier): if schid != self.schid: print(cid, "schid != self.schid"); return (err, ownID) = ts3lib.getClientID(schid) if invokerID == ownID: print(cid, "invokerID == ownID"); return if isPermanent(schid, cid) or isSemiPermanent(schid, cid): print("isPermanent(schid, cid) or isSemiPermanent(schid, cid)"); return (error, maxclients) = ts3lib.getChannelVariable(schid, cid, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS) # (error, maxfamilyclients) = ts3lib.getChannelVariable(schid, cid, ts3defines.ChannelProperties.CHANNEL_MAXFAMILYCLIENTS) if maxclients != -1: clients = channelClientCount(schid, cid) if clients >= maxclients: print(cid, "clients >= maxclients"); return (err, needed_tp) = ts3lib.getChannelVariable(schid, cid, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER) if needed_tp >=0: (err, ownTP) = ts3lib.getClientSelfVariable(schid, ts3defines.ClientPropertiesRare.CLIENT_TALK_POWER) if int(ownTP) < needed_tp: self.request_tp = True (err, pw) = ts3lib.getChannelVariable(schid, cid, ts3defines.ChannelProperties.CHANNEL_FLAG_PASSWORD) if err == ts3defines.ERROR_ok and pw: pw = getChannelPassword(schid, cid, False, False, True) # ts3lib.verifyChannelPassword(schid, cid, pw, "passwordCracker:manual") if not pw: print(cid, "not pw"); return status = getContactStatus(invokerUniqueIdentifier) if status == ContactStatus.BLOCKED: print(cid, invokerUniqueIdentifier, "blocked"); return ts3lib.printMessage(schid, "{} > Joining into {}".format(self.name,channelURL(schid, cid)), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER) ts3lib.requestClientMove(schid, ownID, cid, pw if pw else "123") def onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moveMessage): if schid != self.schid: return (err, ownID) = ts3lib.getClientID(schid) if clientID != ownID: return if not self.request_tp: return self.request_tp = False (err, needed_tp) = ts3lib.getChannelVariable(schid, newChannelID, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER) if needed_tp >=0: (err, ownTP) = ts3lib.getClientSelfVariable(schid, ts3defines.ClientPropertiesRare.CLIENT_TALK_POWER) if int(ownTP) < needed_tp: ts3lib.requestIsTalker(schid, True, "")
class quickPerm(ts3plugin): name = "Quick Permissions" try: apiVersion = getCurrentApiVersion() except: apiVersion = 21 requestAutoload = True version = "1.0" author = "Bluscream" description = "Stolen from NoX by exp111 stolen from Bluscream by DatDraggy" offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [] # (ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "Toggle " + name, "") hotkeys = [] enabled = True permissions = [ ("i_permission_modify_power", 75, True), ("i_client_permission_modify_power", 75, True), ("i_group_modify_power", 75, True), ("i_group_member_add_power", 75, True), ("b_virtualserver_token_add", True, True), ("b_virtualserver_token_list", True, True), ("b_virtualserver_token_use", True, True), ("b_virtualserver_token_delete", True, True), ("b_client_ignore_bans", True, True), ("i_client_ban_power", 75, True), ("i_client_needed_ban_power", 75, True), ("b_client_remoteaddress_view", True, True) ] def __init__(self): if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab("{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded.".format(timestamp(), self.name, self.author)) def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype != ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL or menuItemID != 0: return self.enabled = not self.enabled ts3lib.printMessageToCurrentTab("{} set to [color=orange]{}".format(self.name,self.enabled)) def onServerGroupClientAddedEvent(self, schid, clientID, clientName, clientUniqueIdentity, sgid, invokerClientID, invokerName, invokerUniqueIdentity): if not self.enabled: return if invokerClientID < 1: return (err, ownID) = ts3lib.getClientID(schid) if ownID != clientID: return if invokerClientID == ownID: return (err, dgid) = ts3lib.getServerVariable(schid, ts3defines.VirtualServerPropertiesRare.VIRTUALSERVER_DEFAULT_SERVER_GROUP) if sgid == dgid: return (err, cldbid) = ts3lib.getClientVariable(schid, ownID, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID) for perm in self.permissions: (err, pid) = ts3lib.getPermissionIDByName(schid, perm[0]) v = 100 if sgid == 2 and perm[1] == 75 else perm[1] ts3lib.requestClientAddPerm(schid, cldbid, [pid], [v], [perm[2]], "quickperm") (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID) ts3lib.requestChannelClientAddPerm(schid, ownCID, cldbid, [pid], [v], "quickperm") # ts3lib.requestChannelAddPerm(schid, ownCID, [pid], [v], "quickperm") def onServerErrorEvent(self, schid, errorMessage, error, returnCode, extraMessage): if returnCode == "quickperm": return True def onServerPermissionErrorEvent(self, schid, errorMessage, error, returnCode, failedPermissionID): if returnCode == "quickperm": return True
class nameSwitcher(ts3plugin): name = "Name Switcher" try: apiVersion = getCurrentApiVersion() except: apiVersion = 21 requestAutoload = False version = "1.0" author = "Bluscream" description = "" offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "Toggle " + name, "")] hotkeys = [] timer = QTimer() interval = 1 * 1000 * 60 prefix = "Danny" suffixes = path.join(getPluginPath(), "scripts", "nameSwitcher", "suffixes.txt") last = "" schid = 0 retcode = "" def __init__(self): self.timer.timeout.connect(self.tick) self.timer.setTimerType(2) with open(self.suffixes) as f: self.suffixes = f.read().splitlines() if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab("{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded.".format(timestamp(), self.name, self.author)) def stop(self): if self.timer.isActive(): self.timer.stop() def tick(self): new = choice(self.suffixes) while new == self.last: new = choice(self.suffixes) ts3lib.setClientSelfVariableAsString(self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME, self.prefix + new) self.retcode = ts3lib.createReturnCode() ts3lib.flushClientSelfUpdates(self.schid, self.retcode) self.last = new def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype != ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL or menuItemID != 0: return if self.timer.isActive(): self.timer.stop() else: self.schid = schid self.timer.start(self.interval) self.tick() def onConnectStatusChangeEvent(self, schid, newStatus, errorNumber): if newStatus == ts3defines.ConnectStatus.STATUS_DISCONNECTED: if self.timer.isActive(): self.timer.stop() def onServerErrorEvent(self, schid, errorMessage, error, returnCode, extraMessage): if returnCode != self.retcode: return self.retcode = "" if error == ts3defines.ERROR_client_nickname_inuse: self.tick() return True
def setupValues(self): if self.cfg.getboolean("general", "differentApi", fallback=False): self.differentApiButton.setChecked(Qt.Checked) else: self.differentApiButton.setChecked(Qt.Unchecked) self.requiredApiEdit.setText(pytson.getCurrentApiVersion()) if self.cfg.getboolean("general", "loadAllMenus", fallback=False): self.loadMenusButton.setChecked(Qt.Checked) else: self.loadMenusButton.setChecked(Qt.Unchecked) bgcolor = QColor(self.cfg.get("console", "backgroundColor")).name() self.bgColorButton.setStyleSheet("background-color: %s;" % bgcolor) txtcolor = QColor(self.cfg.get("console", "textColor")).name() self.textColorButton.setStyleSheet("background-color: %s;" % txtcolor) f = QFont(self.cfg.get("console", "fontFamily")) self.fontFamilyCombo.setCurrentFont(f) self.fontSizeSpin.setValue(self.cfg.getint("console", "fontSize")) if self.cfg.getboolean("console", "tabcomplete"): self.tabcompleteButton.setChecked(True) self.spacesButton.setEnabled(False) self.tabwidthSpin.setEnabled(False) self.tabwidthLabel.setEnabled(False) else: self.tabcompleteButton.setChecked(False) self.spacesButton.setChecked(self.cfg.getboolean("console", "spaces")) self.tabwidthSpin.setValue(self.cfg.getint("console", "tabwidth")) self.scriptEdit.setText(self.cfg.get("console", "startup")) self.silentButton.setChecked(self.cfg.getboolean("console", "silentStartup")) self.languageCombo.addItem("Default", "en_US") for loc in pytson.locales(): qloc = QLocale(loc) self.languageCombo.addItem(qloc.nativeLanguageName(), loc) if self.cfg.get("general", "language") == loc: self.languageCombo.setCurrentIndex(self.languageCombo.count - 1) if self.cfg.get("general", "language") == "inherited": self.languageButton.setChecked(True) self.languageCombo.setEnabled(False) if self.cfg.getboolean("general", "verbose"): self.verboseButton.setChecked(True) self.setupList() self.reloadSite()
def setupList(self): self.pluginsTable.clear() self.pluginsTable.setRowCount(len(self.host.plugins)) try: ico = ts3client.IconPack.current() ico.open() except Exception as e: ico = None ts3print(self._tr("Error loading iconpack: {exception}"). format(exception=e), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon.ConfigurationDialog.setupList", 0) row = 0 diffapi = self.cfg.getboolean("general", "differentApi", fallback=False) for key, p in self.host.plugins.items(): if diffapi or p.apiVersion == pytson.getCurrentApiVersion(): item = QTableWidgetItem(p.name) item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) item.setCheckState(Qt.Checked if key in self.host.active else Qt.Unchecked) item.setData(Qt.UserRole, key) self.pluginsTable.setItem(row, 0, item) if p.offersConfigure: setbutton = QToolButton() setbutton.connect("clicked()", lambda n=p.name: self.onSettingsButtonClicked(n)) setbutton.setToolTip(self._tr("Configure")) if ico: setbutton.setIcon(QIcon(ico.icon("SETTINGS"))) self.pluginsTable.setCellWidget(row, 1, setbutton) if p.name not in self.host.active: setbutton.setEnabled(False) rembutton = QToolButton() if ico: rembutton.setIcon(QIcon(ico.icon("DELETE"))) rembutton.connect("clicked()", lambda n=p.name: self.onRemoveButtonClicked(n)) rembutton.setToolTip(self._tr("Remove")) self.pluginsTable.setCellWidget(row, 2, rembutton) row += 1 if ico: ico.close() self.pluginsTable.setRowCount(row) self.pluginsTable.sortItems(0)
class ignoreFirstMessage(ts3plugin): name = "Ignore First Message" try: apiVersion = getCurrentApiVersion() except: apiVersion = 21 requestAutoload = False version = "1.0" author = "Bluscream" description = "Ignores first private message from users." offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "Toggle " + name, "")] hotkeys = [] enabled = True def __init__(self): if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab( "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded." .format(timestamp(), self.name, self.author)) def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype != ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL or menuItemID != 0: return self.enabled = not self.enabled def onTextMessageEvent(self, schid, targetMode, toID, fromID, fromName, fromUniqueIdentifier, message, ffIgnored): if ffIgnored: return False if targetMode != ts3defines.TextMessageTargetMode.TextMessageTarget_CLIENT: return False err, ownID = ts3lib.getClientID(schid) if fromID == ownID: return False err, uid = ts3lib.getClientVariable( schid, fromID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) if getContactStatus(uid) == ContactStatus.FRIEND: return False uid_encoded = b64encode(uid.encode()).decode() (err, suid) = ts3lib.getServerVariable( schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER) suid_encoded = b64encode(suid.encode()).decode() _path = path.join(ts3lib.getConfigPath(), "chats", suid_encoded, "clients", uid_encoded) if PluginHost.cfg.getboolean("general", "verbose"): print(self.name, ">", "path:", _path) if path.exists("{}.html".format(_path)): return False if path.exists("{}.txt".format(_path)): return False return True
class playShot(ts3plugin): name = "PlayShot" try: apiVersion = getCurrentApiVersion() except: apiVersion = 21 requestAutoload = False version = "1.0" author = "Bluscream" description = "" offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "Toggle " + name, "")] hotkeys = []
class joinChannel(ts3plugin): name = "Copy Channel Description" apiVersion = pytson.getCurrentApiVersion() requestAutoload = False version = "1.0" author = "Exp" description = "Copy Channel Descriptions" offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "Print all Channels", ""), (ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL, 1, "Copy Description", "")] hotkeys = [] debug = False def timestamp(self): return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now()) def __init__(self): ts3lib.logMessage( "{0} script for pyTSon by {1} loaded from \"{2}\".".format( self.name, self.author, __file__), ts3defines.LogLevel.LogLevel_INFO, "Python Script", 0) if self.debug: ts3lib.printMessageToCurrentTab( "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded." .format(self.timestamp(), self.name, self.author)) 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)
class banWhitelist(ts3plugin): path = getScriptPath(__name__) name = "Ban Whitelist" try: apiVersion = pytson.getCurrentApiVersion() except: apiVersion = 22 requestAutoload = False version = "1.0" author = "Bluscream" description = "Automatically removes whitelisted IPs from the banlist" offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [] hotkeys = [] suid = "9lBVIDJRSSgAGy+cWJgNlUQRd64=" requested = 0 whitelist = [] def __init__(self): if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab( "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded." .format(timestamp(), self.name, self.author)) def onClientBanFromServerEvent(self, schid, clid, oldChannelID, newChannelID, visibility, kickerID, kickerName, kickerUniqueIdentifier, time, kickMessage): active = PluginHost.active if not "Custom Ban" in active: return (err, suid) = ts3lib.getServerVariable( schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER) if suid != self.suid: return self.requested = schid self.whitelist = active["Custom Ban"].whitelist if len(self.whitelist) < 1: return ts3lib.requestBanList(schid) def onBanListEvent(self, schid, banid, ip, name, uid, creationTime, durationTime, invokerName, invokercldbid, invokeruid, reason, numberOfEnforcements, lastNickName): if self.requested != schid: return if not ip in self.whitelist: return ts3lib.printMessageToCurrentTab( "{}: [color=red]Unbanning whitelisted IP [b]{}".format( self.name, ip)) ts3lib.bandel(schid, banid)
class info(ts3plugin): name = "addBookmarkFix" apiVersion = pytson.getCurrentApiVersion() requestAutoload = True version = "1.0" author = "Exp" description = "Remove links with faulty tags" offersConfigure = False commandKeyword = "" infoTitle = "addBookmarkFix" menuItems = [] hotkeys = [] def timestamp(self): return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now()) def __init__(self): self.dlg = None def onTextMessageEvent(self, schid, targetMode, toID, fromID, fromName, fromUniqueIdentifier, message, ffIgnored): try: messageL = message.lower() bookmarkFind = messageL.find( "addbookmark=") # ts3server://localhost?addbookmark= if (bookmarkFind == -1): return closedFind = messageL.find("]") if (closedFind == -1): return tagFind = messageL.find("<") if (tagFind == -1): return if (tagFind > closedFind or tagFind < bookmarkFind): return ts3.printMessageToCurrentTab( "[color=red]{0} send a faulty link[/color]".format(fromName)) return True # ignore msg except: from traceback import format_exc ts3.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon", 0)
class showQueries(ts3plugin): name = "Query Viewer" import pytson;apiVersion = pytson.getCurrentApiVersion() requestAutoload = False version = "1.0" author = "Bluscream" description = "Shows you queries in channels.\n\nHomepage: https://github.com/Bluscream/Extended-Info-Plugin\n\n\nCheck out https://r4p3.net/forums/plugins.68/ for more plugins." offersConfigure = False commandKeyword = "" infoTitle = "[b]Queries:[/b]" menuItems = [] hotkeys = [] debug = False def timestamp(self): return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now()) def __init__(self): ts3lib.logMessage("{0} script for pyTSon by {1} loaded from \"{2}\".".format(self.name,self.author,__file__), ts3defines.LogLevel.LogLevel_INFO, "Python Script", 0) if self.debug: ts3lib.printMessageToCurrentTab("{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded.".format(self.timestamp(),self.name,self.author)) def clientURL(self, schid=None, clid=1, uid=None, nickname=None, encodednick=None): if schid == None: try: schid = ts3lib.getCurrentServerConnectionHandlerID() except: pass if uid == None: try: (error, uid) = ts3lib.getClientVariableAsString(schid, clid, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) except: pass if nickname == None: try: (error, nickname) = ts3lib.getClientVariableAsString(schid, clid, ts3defines.ClientProperties.CLIENT_NICKNAME) except: nickname = uid if encodednick == None: try: encodednick = urlencode(nickname) except: pass return "[url=client://{0}/{1}~{2}]{3}[/url]".format(clid, uid, encodednick, nickname) def infoData(self, schid, id, atype): try: if atype == ts3defines.PluginItemType.PLUGIN_CHANNEL: (error, clist) = ts3lib.getChannelClientList(schid, id) i = [] for c in clist: (error, clienttype) = ts3lib.getClientVariableAsInt(schid, c, ts3defines.ClientPropertiesRare.CLIENT_TYPE) if clienttype == ts3defines.ClientType.ClientType_SERVERQUERY: i.append(self.clientURL(schid,c)) if len(i) < 1: return else: return i except: return
class autoServerGroup(ts3plugin): name = "Auto Server Group" try: apiVersion = getCurrentApiVersion() except: apiVersion = 21 requestAutoload = False version = "1.0" author = "Bluscream" description = "" offersConfigure = False commandKeyword = "disconnect" infoTitle = None menuItems = [] hotkeys = [] added = 0 clid = 0 sgids = [28,27,26,21,17,16,9] sgid = 83 description = "{:%d.%m %H:%M:%S} | {invokerName}" def __init__(self): if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab("{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded.".format(timestamp(), self.name, self.author)) def onServerGroupClientAddedEvent(self, schid, clid, clientName, clientUniqueIdentity, sgid, invokerClientID, invokerName, invokerUniqueIdentity): if sgid in self.sgids: err, description = ts3lib.getClientVariable(schid, clid, ts3defines.ClientPropertiesRare.CLIENT_DESCRIPTION) print("description:", description) if re.match(".*\d\d.\d\d \d\d:\d\d:\d\d | .*", description): return description = "{} {}".format(description, self.description.format(datetime.now(),invokerName=invokerName)) ts3lib.requestClientEditDescription(schid, clid, description) def onServerGroupClientDeletedEvent(self, schid, clid, clientName, clientUniqueIdentity, sgid, invokerClientID, invokerName, invokerUniqueIdentity): err, sgids = ts3lib.getClientVariableAsString(schid, clid, ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS) print("Servergroups",sgids) sgids = intList(sgids) if any(x in self.sgids for x in sgids): print("true") def onUpdateClientEvent(self, schid, clid, invokerID, invokerName, invokerUniqueIdentifier): if clid != self.clid: return self.clid = 0 err, description = ts3lib.getClientVariable(schid, clid, ts3defines.ClientPropertiesRare.CLIENT_DESCRIPTION) description = "{} {}: {}".format(description, timestamp(), invokerID) ts3lib.requestClientEditDescription(schid, clid, description)
class aaa_ts3Ext(ts3plugin): name = "aaa_ts3Ext" try: apiVersion = getCurrentApiVersion() except: apiVersion = 22 requestAutoload = True version = "1.0" author = "Bluscream" description = "ts3Ext library implementation" offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [] hotkeys = [] guiLogLvl = logLevel.ALL def __init__(self): self.ts3host = ts3SessionHost(self) if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab("{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded.".format(timestamp(), self.name, self.author)) def stop(self): del self.ts3host
class teaspeakBot(ts3plugin): name = "TeaSpeak Bot" try: apiVersion = getCurrentApiVersion() except: apiVersion = 21 requestAutoload = False version = "1.0" author = "Bluscream" description = "" offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [] hotkeys = [] servers = { "siAK/P4hf0ntXOfy3TaW3GwkoPA=": [15, 18, 23], } def __init__(self): if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab( "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded." .format(timestamp(), self.name, self.author)) def onNewChannelCreatedEvent(self, schid, cid, channelParentID, clid, invokerName, invokerUniqueIdentifier): (err, suid) = ts3lib.getServerVariable( schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER) if not suid in self.servers: return (err, sgids) = ts3lib.getClientVariable( schid, clid, ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS) if not set(sgids).isdisjoint(self.servers[suid]): return (err, perm) = ts3lib.getChannelVariable( schid, cid, ts3defines.ChannelProperties.CHANNEL_FLAG_PERMANENT) # (err, semi) = ts3lib.getChannelVariable(schid, cid, ts3defines.ChannelProperties.CHANNEL_FLAG_SEMI_PERMANENT) if not perm: return ts3lib.setChannelVariableAsInt( schid, cid, ts3defines.ChannelProperties.CHANNEL_FLAG_PERMANENT, 0) ts3lib.flushChannelUpdates(schid, cid)
class antiSpam(ts3plugin): name = "Anti Spam" apiVersion = 22 try: apiVersion = pytson.getCurrentApiVersion() except: apiVersion = 21 version = "1.0" author = "Bluscream" description = "" offersConfigure = False commandKeyword = "" infoTitle = None hotkeys = [] menuItems = [] @staticmethod def timestamp(): return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now()) def __init__(self): if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab("{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded.".format(self.timestamp(),self.name,self.author)) def onTextMessageEvent(self, schid, targetMode, toID, fromID, fromName, fromUniqueIdentifier, message, ffIgnored): pass
class debugTool(ts3plugin): name = "DebugTool" apiVersion = pytson.getCurrentApiVersion() requestAutoload = True version = "1.0" author = "Exp" description = "" offersConfigure = False commandKeyword = "" infoTitle = "" menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT, 0, "Debug", "")] hotkeys = [] debug = False def __init__(self): if self.debug: ts3.printMessageToCurrentTab( '[{:%Y-%m-%d %H:%M:%S}]'.format(datetime.datetime.now()) + " [color=orange]" + self.name + "[/color] Plugin for pyTSon by " + self.author + " loaded.") def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if menuItemID == 0: ts3.requestClientVariables(schid, selectedItemID, "") shit = "[COLOR=red]" shit += ts3.getClientDisplayName( schid, selectedItemID)[1] + " (" + str(selectedItemID) + "):\n" shit += "Unique ID: " + ts3.getClientVariableAsString( schid, selectedItemID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)[1] + "\n" shit += "MetaData: " + ts3.getClientVariableAsString( schid, selectedItemID, ts3defines.ClientProperties.CLIENT_META_DATA)[1] + "\n" shit += "IsTalking: " + ts3.getClientVariableAsString( schid, selectedItemID, ts3defines.ClientProperties.CLIENT_FLAG_TALKING)[1] + "\n" shit += "[/COLOR]" ts3.printMessageToCurrentTab(shit)
class fakeMuter(ts3plugin): name = "fakeMuter" apiVersion = pytson.getCurrentApiVersion() requestAutoload = True version = "1.0" author = "Exp" description = "" offersConfigure = False commandKeyword = "" infoTitle = "" menuItems = [] hotkeys = [("fakeMute", "fakeMute")] debug = False enabled = False changeName = True def __init__(self): ts3.printMessageToCurrentTab( '[{:%Y-%m-%d %H:%M:%S}]'.format(datetime.datetime.now()) + " [color=orange]" + self.name + "[/color] Plugin for pyTSon by " + self.author + " loaded.") def onHotkeyEvent(self, keyword): if keyword == "fakeMute": self.enabled = not self.enabled if self.changeName: name = ts3.getClientDisplayName(1, ts3.getClientID(1), 128) if enabled: ts3.setClientSelfVariableAsString( 1, ts3defines.CLIENT_NICKNAME, name + " [MUTED]") else: ts3.setClientSelfVariableAsString( 1, ts3defines.CLIENT_NICKNAME, name[:-8]) ts3.flushClientSelfUpdates(1, "") def onEditPlaybackVoiceDataEvent(self, clientID, samples, sampleCount, channels): if self.enabled: samples = 0
class TS3AB(ts3plugin): path = getScriptPath(__name__) name = "TS3AB" try: apiVersion = getCurrentApiVersion() except: apiVersion = 21 requestAutoload = False version = "1.0" author = "Bluscream" description = "" offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [] hotkeys = [] def __init__(self): if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab( "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded." .format(timestamp(), self.name, self.author)) def onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moveMessage): (err, ownID) = ts3lib.getClientID(schid) if clientID != ownID: return (err, needed_tp) = ts3lib.getChannelVariable( schid, newChannelID, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER) if needed_tp >= 0: # (err, hasTP) = ts3lib.getClientSelfVariable(schid, ts3defines.ClientPropertiesRare.CLIENT_IS_TALKER) (err, ownTP) = ts3lib.getClientSelfVariable( schid, ts3defines.ClientPropertiesRare.CLIENT_TALK_POWER) if int(ownTP) < needed_tp: ts3lib.requestSendPrivateTextMsg( schid, self.text, self.servers[schid]["clid"], self.retcode) # ts3lib.requestIsTalker(schid, True, "")
class joinChannel(ts3plugin): name = "Copy Channel Description" apiVersion = pytson.getCurrentApiVersion() requestAutoload = False version = "1.0" author = "Exp" description = "Copy Channel Descriptions" offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL, 0, "Copy Description", "")] hotkeys = [] debug = False def timestamp(self): return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now()) def __init__(self): ts3lib.logMessage( "{0} script for pyTSon by {1} loaded from \"{2}\".".format( self.name, self.author, __file__), ts3defines.LogLevel.LogLevel_INFO, "Python Script", 0) if self.debug: ts3lib.printMessageToCurrentTab( "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded." .format(self.timestamp(), self.name, self.author)) def onMenuItemEvent(self, schid, atype, menuItemID, channel): try: description = ts3lib.getChannelVariableAsString( schid, channel, ts3defines.ChannelProperties.CHANNEL_DESCRIPTION)[1] ts3lib.printMessageToCurrentTab(description) except: from traceback import format_exc ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
class info(ts3plugin): name = "DisconnectCMD" apiVersion = pytson.getCurrentApiVersion() requestAutoload = True version = "1.0" author = "Exp" description = "Disconnect via /py disconnect" offersConfigure = False commandKeyword = "dc" infoTitle = None menuItems = [] hotkeys = [] def timestamp(self): return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now()) def __init__(self): self.dlg = None def processCommand(self, schid, command): ts3.printMessageToCurrentTab("Disconnecting") ts3.stopConnection(schid, "Disconnected via Pytson Script") return True