コード例 #1
0
class countNick(ts3plugin):
    name = "Count Nickname"
    apiVersion = 22
    requestAutoload = False
    version = "1.0"
    author = "Bluscream"
    description = "\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,
                  "Toggle Auto incrementing nickname", "")]
    hotkeys = []
    timer = None
    debug = False
    prefix = "Ich bin "
    suffix = " jahre alt"
    count = 0

    @staticmethod
    def timestamp():
        return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now())

    def __init__(self):
        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, selectedItemID):
        if menuItemID == 0:
            if self.timer == None:
                self.timer = QTimer()
                self.timer.timeout.connect(self.tick)
            if self.timer.isActive():
                self.timer.stop()
                self.timer = None
                ts3lib.printMessageToCurrentTab('Timer stopped!')
            else:
                self.timer.start(1000)
                ts3lib.printMessageToCurrentTab('Timer started!')
            ts3lib.printMessageToCurrentTab(
                "{0}Set {1} to [color=yellow]{2}[/color]".format(
                    self.timestamp(), self.name, self.toggle))

    def tick(self, schid=0, clid=0):
        if schid == 0: schid = ts3lib.getCurrentServerConnectionHandlerID()
        if schid == 0: return
        _newnick = '%s%s%s' % (self.prefix, self.count, self.suffix)
        if self.debug:
            ts3lib.printMessageToCurrentTab('Tick %s: ' % self.count +
                                            _newnick)
        ts3lib.setClientSelfVariableAsString(
            schid, ts3defines.ClientProperties.CLIENT_NICKNAME, _newnick)
        ts3lib.flushClientSelfUpdates(schid)
        self.count += 1
コード例 #2
0
 def onMenuItemEvent(self, serverConnectionHandlerID, atype, menuItemID,
                     selectedItemID):
     if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL:
         if menuItemID == 0:
             timer = QTimer(self)
             connect(
                 timer, SIGNAL(timeout()), this,
                 SLOT(
                     self.changeName(serverConnectionHandlerID,
                                     names[self.i])))
             timer.start(5000)
コード例 #3
0
ファイル: __init__.py プロジェクト: jelidi/pyTSon_plugins
class autoCommander(ts3plugin):
    name = "Auto Channel Commander"
    apiVersion = 22
    requestAutoload = False
    version = "1.0"
    author = "Bluscream"
    description = "Automatically enable channel commander when switching channels.\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,
                  "Toggle Auto Channel Commander", ""),
                 (ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 1,
                  "Toggle Channel Commander Spam", "")]
    hotkeys = []
    debug = False
    toggle = False
    timer = None
    schid = 0
    current = False
    requested = False
    mod_names = ["ADMIN", "MOD", "OPERATOR"]
    smgroup = []

    @staticmethod
    def timestamp():
        return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now())

    def __init__(self):
        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 toggleTimer(self, schid):
        if self.timer is None:
            self.timer = QTimer()
            self.timer.timeout.connect(self.tick)
        if self.timer.isActive():
            self.timer.stop()
            self.timer = None
            ts3lib.printMessageToCurrentTab('Timer stopped!')
        else:
            step = inputBox(self.name, 'Interval in Milliseconds:')
            if step: interval = int(step)
            else: interval = 1000
            self.schid = schid
            self.timer.start(interval)
            ts3lib.printMessageToCurrentTab('Timer started!')

    def tick(self):
        self.current = not self.current
        ts3lib.setClientSelfVariableAsInt(
            self.schid,
            ts3lib.ClientPropertiesRare.CLIENT_IS_CHANNEL_COMMANDER,
            self.current)
        ts3lib.flushClientSelfUpdates(self.schid)

    def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
        if menuItemID == 0:
            self.toggle = not self.toggle
            ts3lib.printMessageToCurrentTab(
                "{0}Set {1} to [color=yellow]{2}[/color]".format(
                    self.timestamp(), self.name, self.toggle))
        elif menuItemID == 1:
            self.toggleTimer(schid)

    def onConnectStatusChangeEvent(self, serverConnectionHandlerID, newStatus,
                                   errorNumber):
        if not self.toggle: return
        if newStatus == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHING:
            self.requested = True
            ts3lib.requestChannelGroupList(
                ts3lib.getCurrentServerConnectionHandlerID())

    def onChannelGroupListEvent(self, serverConnectionHandlerID,
                                channelGroupID, name, atype, iconID, saveDB):
        if not self.toggle: return
        if self.requested == True:
            for _name in self.mod_names:
                if name.upper().__contains__(_name):
                    self.smgroup.extend([channelGroupID])

    def onChannelGroupListFinishedEvent(self, serverConnectionHandlerID):
        if self.toggle: self.requested = False

    # def onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moveMessage):
    #if not self.toggle: return
#         (error, cID) = ts3lib.getClientID(schid)
#         if error == ts3defines.ERROR_ok:
#             if cID == clientID:
#                 ts3lib.setClientSelfVariableAsInt(schid, ts3defines.ClientPropertiesRare.CLIENT_IS_CHANNEL_COMMANDER, 1)
#                 ts3lib.flushClientSelfUpdates(schid)
#
# def onClientMoveMovedEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moverID, moverName, moverUniqueIdentifier, moveMessage):
#     if not self.toggle: return
#         (error, cID) = ts3lib.getClientID(schid)
#         if error == ts3defines.ERROR_ok:
#             if cID == clientID:
#                 ts3lib.setClientSelfVariableAsInt(schid, ts3defines.ClientPropertiesRare.CLIENT_IS_CHANNEL_COMMANDER, 1)
#                 ts3lib.flushClientSelfUpdates(schid)

    def onClientChannelGroupChangedEvent(self, schid, channelGroupID,
                                         channelID, clientID, invokerClientID,
                                         invokerName, invokerUniqueIdentity):
        if not self.toggle: return
        (error, cID) = ts3lib.getClientID(schid)
        if error == ts3defines.ERROR_ok:
            if cID == clientID:
                (error, cgID) = ts3lib.getClientVariableAsInt(
                    schid, cID,
                    ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID)
                for _group in self.smgroup:
                    if cgID == _group:
                        ts3lib.setClientSelfVariableAsInt(
                            schid, ts3defines.ClientPropertiesRare.
                            CLIENT_IS_CHANNEL_COMMANDER, 1)
                        ts3lib.flushClientSelfUpdates(schid)
                        break
コード例 #4
0
class pingNick(ts3plugin):
    name = "Ping Nickname"

    apiVersion = 22
    requestAutoload = False
    version = "1.0"
    author = "Bluscream"
    description = "Automatically enable channel commander when switching channels.\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,
                  "Toggle Auto Ping as nickname", "")]
    hotkeys = []
    timer = None
    debug = False
    prefix = ""
    suffix = "ms :O"
    int = 0
    lastPing = 0

    @staticmethod
    def timestamp():
        return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now())

    def __init__(self):
        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, selectedItemID):
        if menuItemID == 0:
            if self.timer == None:
                self.timer = QTimer()
                self.timer.timeout.connect(self.tick)
            if self.timer.isActive():
                self.timer.stop()
                self.timer = None
                ts3lib.printMessageToCurrentTab('Timer stopped!')
            else:
                self.timer.start(1000)
                ts3lib.printMessageToCurrentTab('Timer started!')
            ts3lib.printMessageToCurrentTab(
                "{0}Set {1} to [color=yellow]{2}[/color]".format(
                    self.timestamp(), self.name, self.toggle))

    def tick(self, schid=0, clid=0):
        if schid == 0: schid = ts3lib.getCurrentServerConnectionHandlerID()
        if clid == 0: (err, clid) = ts3lib.getClientID(schid)
        if schid == 0 or clid == 0: return
        if self.debug:
            self.int += 1
            ts3lib.printMessageToCurrentTab('Tick %s' % self.int)
        (err, ping) = ts3lib.getConnectionVariableAsUInt64(
            schid, clid, ts3defines.ConnectionProperties.CONNECTION_PING)
        if ping == self.lastPing: return
        ts3lib.setClientSelfVariableAsString(
            schid, ts3defines.ClientProperties.CLIENT_NICKNAME,
            "{0}{1}{2}".format(self.prefix, ping, self.suffix))
        ts3lib.flushClientSelfUpdates(schid)
        self.lastPing = ping
コード例 #5
0
ファイル: __init__.py プロジェクト: spyderwan/pyTSon_plugins
class showQueries(ts3plugin):
    name = "Query Viewer"
    apiVersion = 22
    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 = "query"
    infoTitle = "[b]Queries:[/b]"
    menuItems = []
    hotkeys = []
    debug = False
    timer = QTimer()
    cleartimer = QTimer()
    schid = 0
    queries = []
    hqueries = []
    hqueries_cache = []
    query_uids = ["serveradmin", "ServerQuery"]
    waitingFor = ""
    retcode = ""

    def __init__(self):
        self.cleartimer.timeout.connect(self.clearQueries)
        self.cleartimer.start(1000*18000)
        if self.debug: ts3lib.printMessageToCurrentTab("[{0} {1}] [color=orange]{2}[/color] Plugin for pyTSon by [url=https://github.com/{3}]{4}[/url] loaded.".format(date(), Time(), self.name, self.author))

    def stop(self):
        self.timer.stop()
        self.timer = None
        del self.timer
        self.timer = QTimer()

    def onConnectStatusChangeEvent(self, schid, status, errorNumber):
        if status == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED:
            self.schid = schid
            self.timer.timeout.connect(self.checkQueries)
            self.timer.start(1000)
            ts3lib.printMessageToCurrentTab('Timer started!')
        elif status == ts3defines.ConnectStatus.STATUS_DISCONNECTED:
            if self.timer.isActive():
                self.timer.stop()
                self.schid = 0
                ts3lib.printMessageToCurrentTab('Timer stopped!')

    def checkQueries(self):
        (err, clist) = ts3lib.getClientList(self.schid)
        for c in clist:
            if c in self.queries:
                continue
            else:
                (err, ctype) = ts3lib.getClientVariable(self.schid, c, ts3defines.ClientPropertiesRare.CLIENT_TYPE)
                if ctype != ts3defines.ClientType.ClientType_SERVERQUERY: continue
                self.queries.append(c)
                (err, cid) = ts3lib.getChannelOfClient(self.schid, c)
                # (err, channelname) = ts3lib.getChannelVariable(self.schid, cid, ts3defines.ChannelProperties.CHANNEL_NAME)
                ts3lib.printMessage(self.schid, "<{0}> Found Query {1} in channel {2}".format(Time(), clientURL(self.schid, c), channelURL(self.schid, cid)), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER)
        # self.waitingFor = self.query_uids[0]
        # self.retcode = ts3lib.createReturnCode()
        # ts3lib.requestClientIDs(self.schid, self.query_uids[0], self.retcode)

    def clearQueries(self):
        self.queries = []
        ts3lib.printMessage(self.schid, "<{0}> Cleared Query List".format(Time()), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER)

    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.getClientVariable(schid, c, ts3defines.ClientPropertiesRare.CLIENT_TYPE)
                    if clienttype == ts3defines.ClientType.ClientType_SERVERQUERY:
                        i.append(clientURL(schid, c))
                if len(i) < 1: return
                else: return i
        except: return

    def onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moveMessage):
        # if oldChannelID != 0: return
        (err, clienttype) = ts3lib.getClientVariable(schid, clientID, ts3defines.ClientPropertiesRare.CLIENT_TYPE)
        if clienttype != ts3defines.ClientType.ClientType_SERVERQUERY: return
        # (err, channelname) = ts3lib.getChannelVariable(schid, newChannelID, ts3defines.ChannelProperties.CHANNEL_NAME)
        if visibility == ts3defines.Visibility.ENTER_VISIBILITY:
            ts3lib.printMessage(schid, "<{0}> {1} enters view to channel {2}".format(Time(), clientURL(schid, clientID), channelURL(schid, newChannelID)), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER)
        elif visibility == ts3defines.Visibility.LEAVE_VISIBILITY:
            ts3lib.printMessage(schid, "<{0}> {1} leaves from channel {2}{3}".format(Time(), clientURL(schid, clientID), channelURL(schid, oldChannelID), " ({})".format(moveMessage) if moveMessage else ""), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER)
        else: ts3lib.printMessage(schid, "<{0}> {1} switched from channel {2} to {3}".format(Time(), clientURL(schid, clientID), channelURL(schid, oldChannelID), channelURL(schid, newChannelID)), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER)
        # <16:11:43> "charlie sheen" switched from channel "Intros Gratis <3" to "Serverteam-Gesucht Builder"

    def onClientIDsEvent(self, schid, uid, clid, nickname):
        # print('{0} == {1}: {2}'.format(uid, self.waitingFor, uid == self.waitingFor))
        if not uid == self.waitingFor: return
        (err, chan) = ts3lib.getChannelOfClient(schid, clid)
        if err != ts3defines.ERROR_ok: self.hqueries.append((clid, uid, nickname))

    def onClientIDsFinishedEvent(self, schid):
        if not self.waitingFor in self.query_uids: return
        if len(self.hqueries) > 0:
            # qstring = ", ".join("[url=client://{0}/{1}]{2}[/url]".format(tup) for tup in self.queries)
            qlist = ["[url=client://{}/{}]{}[/url]".format(*tup) for tup in self.hqueries]
            qstring = ", ".join(qlist)
            ts3lib.printMessage(schid, "<{0}> Found {1} hidden Queries with UID \"{2}\": {3}".format(Time(), len(self.hqueries), self.waitingFor, qstring), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER)
            self.hqueries = []
        if self.waitingFor == self.query_uids[0]:
            self.waitingFor = self.query_uids[-1]
            ts3lib.requestClientIDs(schid, self.query_uids[-1], self.retcode)
        if self.waitingFor == self.query_uids[-1]:
            self.waitingFor = False

    def onServerErrorEvent(self, schid, errorMessage, error, returnCode, extraMessage):
        if returnCode == self.retcode: return True

    def printQueries(self):
        (err, schids) = ts3lib.getServerConnectionHandlerList()
        for schid in schids:
            (err, cids) = ts3lib.getChannelList(schid)
            for cid in cids:
                (err, clids) = ts3lib.getChannelClientList(schid, cid)
                msg = []
                for clid in clids:
                    (err, ctype) = ts3lib.getClientVariable(schid, clid, ts3defines.ClientPropertiesRare.CLIENT_TYPE)
                    if ctype != ts3defines.ClientType.ClientType_SERVERQUERY: continue
                    msg.append(clientURL(schid, clid))
                if len(msg) < 1: continue
                ts3lib.printMessage(schid, "<{0}> {1} has [b]{2}[/b] Query Clients: {3}".format(Time(), channelURL(schid, cid), len(msg), ", ".join(msg)), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER)
            self.waitingFor = self.query_uids[0]
            self.retcode = ts3lib.createReturnCode()
            ts3lib.requestClientIDs(schid, self.query_uids[0], self.retcode)

    def processCommand(self, schid, cmd):
        cmd = cmd.split(' ', 1)
        command = cmd[0].lower()
        if command == "list":
            self.printQueries()
        return 1
コード例 #6
0
class passwordCracker(ts3plugin):
    name = "PW Cracker"
    apiVersion = 22
    requestAutoload = True
    version = "1.0"
    author = "Bluscream"
    description = "<insert lenny face here>"
    offersConfigure = False
    commandKeyword = ""
    infoTitle = "[b]Cracking Password...[/b]"
    menuItems = [
        (PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "== {0} ==".format(name),
         ""), (PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 1, "Stop Cracker", ""),
        (PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 2, "Add PW to cracker", ""),
        (PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 10, "== {0} ==".format(name),
         ""),
        (PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL, 11, "== {0} ==".format(name),
         ""),
        (PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL, 1, "Crack PW (Dictionary)",
         ""),
        (PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL, 2, "Crack PW (Bruteforce)",
         ""),
        (PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL, 3, "Add PW to cracker", ""),
        (PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL, 4, "Try Password", ""),
        (PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL, 12, "== {0} ==".format(name),
         "")
    ]
    hotkeys = []
    debug = False
    pwpath = os.path.join(pytson.getPluginPath(), "scripts", __name__,
                          "pws.txt")
    schid = 0
    cid = 0
    pws = []
    pwc = 0
    cracking = False
    flooding = False
    timer = QTimer()
    interval = 300
    antiflood_delay = 2500
    step = 1
    retcode = ""
    mode = 0
    dlg = None
    status = ""
    requested = False

    def __init__(self):
        content = []
        with open(self.pwpath, encoding="utf8") as f:
            content = f.readlines()
        self.pws = [x.strip() for x in content]
        self.timer.timeout.connect(self.tick)
        ts3lib.requestServerVariables(
            ts3lib.getCurrentServerConnectionHandlerID())
        if self.debug:
            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.timer.stop()
        self.timer = None
        del self.timer
        self.timer = QTimer()

    def menuCreated(self):
        if not self.name in PluginHost.active: return
        for id in [0, 10, 11, 12]:
            ts3lib.setPluginMenuEnabled(PluginHost.globalMenuID(self, id),
                                        False)

    def startTimer(self, schid=0, cid=0):
        if schid != 0: self.schid = schid
        if cid != 0: self.cid = cid
        self.timer.start(self.interval)
        self.tick()
        ts3lib.requestInfoUpdate(self.schid, PluginItemType.PLUGIN_CHANNEL,
                                 self.cid)

    def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
        if atype == PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL:
            if menuItemID == 0:
                if not self.dlg: self.dlg = StatusDialog(self)
                self.dlg.show()
                self.dlg.raise_()
                self.dlg.activateWindow()
            elif menuItemID == 1:
                (err, haspw) = ts3lib.getChannelVariable(
                    schid, selectedItemID,
                    ChannelProperties.CHANNEL_FLAG_PASSWORD)
                if not haspw:
                    (err, name) = ts3lib.getChannelVariable(
                        schid, selectedItemID, ChannelProperties.CHANNEL_NAME)
                    msgBox(
                        "Channel \"{0}\" has no password to crack!".format(
                            name), QMessageBox.Warning)
                    return
                self.mode = 0
                self.step = 1
                self.pwc = 0
                self.startTimer(schid, selectedItemID)
            elif menuItemID == 2:
                (err, haspw) = ts3lib.getChannelVariable(
                    schid, selectedItemID,
                    ChannelProperties.CHANNEL_FLAG_PASSWORD)
                if not haspw:
                    (err, name) = ts3lib.getChannelVariable(
                        schid, selectedItemID, ChannelProperties.CHANNEL_NAME)
                    msgBox(
                        "Channel \"{0}\" has no password to crack!".format(
                            name), QMessageBox.Warning)
                    return
                self.mode = 1
                step = inputBox(self.name, 'How much to increase per try?')
                if step: self.step = int(step)
                start = inputBox(self.name, 'Where to start?')
                if start: self.pwc = int(start)
                self.startTimer(schid, selectedItemID)
            elif menuItemID == 3:
                (err, path,
                 pw) = ts3lib.getChannelConnectInfo(schid, selectedItemID)
                if pw == None or pw == False or pw == "":
                    (err, name) = ts3lib.getChannelVariable(
                        schid, selectedItemID, ChannelProperties.CHANNEL_NAME)
                    msgBox('No password saved for channel {0}'.format(name))
                    return
                elif pw in self.pws:
                    msgBox(
                        "Not adding \"{0}\" to password db\n\nIt already exists!"
                        .format(pw), QMessageBox.Warning)
                    return
                self.pws.append(pw)
                with open(self.pwpath, "a") as myfile:
                    myfile.write('\n{0}'.format(pw))
                msgBox("Added \"{0}\" to password db".format(pw))
            elif menuItemID == 4:
                (err, name) = ts3lib.getChannelVariable(
                    schid, selectedItemID, ChannelProperties.CHANNEL_NAME)
                pw = inputBox("{0} - {1}".format(self.name, name), "Password:"******"passwordCracker:manual")
        elif atype == PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL:
            if menuItemID == 1:
                self.timer.stop()
                ts3lib.printMessageToCurrentTab('Timer stopped!')
            elif menuItemID == 2:
                pw = inputBox("Enter Channel Password to add", "Password:"******"":
                    msgBox("Not adding \"{0}\" to password db".format(pw),
                           QMessageBox.Warning)
                    return
                elif pw in self.pws:
                    msgBox(
                        "Not adding \"{0}\" to password db\n\nIt already exists!"
                        .format(pw), QMessageBox.Warning)
                    return
                self.pws.append(pw)
                with open(self.pwpath, "a") as myfile:
                    myfile.write('\n{0}'.format(pw))
                msgBox("Added \"{0}\" to password db".format(pw))

    def infoData(self, schid, id, atype):
        if not atype == PluginItemType.PLUGIN_CHANNEL: return None
        if not self.cid == id: return None
        if not self.schid == schid: return None
        if self.mode == 0:
            msg = "Trying: {0} / {1}\nCurrent: {2}\nStatus: {3}".format(
                self.pwc + 1,
                len(self.pws) + 1, self.pws[self.pwc], self.status)
        elif self.mode == 1:
            msg = "Trying: {0}\nStatus: {1}".format(self.pwc, self.status)
        return [msg]

    def tick(self):
        try:
            self.retcode = ts3lib.createReturnCode()
            if self.mode == 0:
                if self.pwc >= len(self.pws):
                    self.timer.stop()
                    (err, name) = ts3lib.getChannelVariable(
                        self.schid, self.cid, ChannelProperties.CHANNEL_NAME)
                    msgBox(
                        "Password for channel \"{0}\" was not found :(\n\nTried {1} passwords."
                        .format(name, self.pwc + 1))
                    self.cracking = False
                    return
                pw = self.pws[self.pwc]
            elif self.mode == 1:
                pw = str(self.pwc)
            err = ts3lib.verifyChannelPassword(self.schid, self.cid, pw,
                                               self.retcode)
            if err != ERROR_ok:
                (er, status) = ts3lib.getErrorMessage(err)
                print(
                    'ERROR {0} ({1}) while trying password \"{2}\" for channel #{3} on server #{4}'
                    .format(status, err, pw, self.cid, self.schid))
            # else: print('[{0}] Trying password \"{1}\" for channel #{2} on server #{3}'.format(self.pwc, pw, self.cid, self.schid))
            if not self.flooding: self.pwc += self.step
        except:
            from traceback import format_exc
            ts3lib.logMessage(format_exc(), LogLevel.LogLevel_ERROR, "pyTSon",
                              0)

    def onServerErrorEvent(self, schid, errorMessage, error, returnCode,
                           extraMessage):
        if returnCode == "passwordCracker:manual":
            (err,
             name) = ts3lib.getChannelVariable(schid, self.cid,
                                               ChannelProperties.CHANNEL_NAME)
            errorMessage = errorMessage.title()
            msgBox("Channel: {0}\n\nPW: {1}\n\nResult: {2}".format(
                name, self.pw, errorMessage))
        if not returnCode == self.retcode: return
        errorMessage = errorMessage.title()
        if error == ERROR_channel_invalid_password:
            if self.flooding: self.flooding = False
            self.status = '[color=orange]{0}[/color]'.format(errorMessage)
            ts3lib.requestInfoUpdate(schid, PluginItemType.PLUGIN_CHANNEL,
                                     self.cid)
        elif error == ERROR_client_is_flooding:
            self.flooding = True
            self.timer.stop()
            QTimer.singleShot(self.antiflood_delay, self.startTimer)
            self.status = '[color=red]{0}[/color]'.format(errorMessage)
            ts3lib.requestInfoUpdate(schid, PluginItemType.PLUGIN_CHANNEL,
                                     self.cid)
        elif error == ERROR_channel_invalid_id:
            self.timer.stop()
            self.status = '[color=red]{0}[/color]'.format(errorMessage)
            ts3lib.requestInfoUpdate(schid, PluginItemType.PLUGIN_CHANNEL,
                                     self.cid)
            msgBox(
                "Channel #{0} is invalid!\n\nStopping Cracker!".format(
                    self.cid), QMessageBox.Warning)
        elif error == ERROR_ok:
            if self.flooding: self.flooding = False
            self.timer.stop()
            (err,
             name) = ts3lib.getChannelVariable(schid, self.cid,
                                               ChannelProperties.CHANNEL_NAME)
            ts3lib.printMessageToCurrentTab(
                'Channel: {0} Password: \"{1}\"'.format(
                    channelURL(schid, self.cid, name),
                    self.pws[self.pwc -
                             1] if self.mode == 0 else self.pwc - 1))
            self.status = '[color=green]{0}[/color]'.format(errorMessage)
            ts3lib.requestInfoUpdate(schid, PluginItemType.PLUGIN_CHANNEL,
                                     self.cid)
            if confirm(
                    "Password found! ({0} / {1})".format(
                        self.pwc, len(self.pws))
                    if self.mode == 0 else "Password found!",
                    "Password \"{0}\" was found for channel \"{1}\"\n\nDo you want to join now?"
                    .format(
                        self.pws[self.pwc -
                                 1] if self.mode == 0 else self.pwc - 1,
                        name)):
                (err, ownID) = ts3lib.getClientID(schid)
                ts3lib.requestClientMove(
                    schid, ownID, self.cid,
                    self.pws[self.pwc -
                             1] if self.mode == 0 else str(self.pwc - 1))
        else:
            self.status = errorMessage
            ts3lib.requestInfoUpdate(schid, PluginItemType.PLUGIN_CHANNEL,
                                     self.cid)
        if error in [ERROR_channel_invalid_id, ERROR_ok
                     ] or returnCode in ["passwordCracker:manual"]:
            self.cracking = False
        return True

    def onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID,
                          visibility, moveMessage):
        pass

    def onUpdateChannelEditedEvent(self, schid, channelID, invokerID,
                                   invokerName, invokerUniqueIdentifier):
        if not self.cracking: return
        if not self.cid == channelID: return
        if not self.schid == schid: return
        (err, haspw) = ts3lib.getChannelVariable(
            schid, channelID, ChannelProperties.CHANNEL_FLAG_PASSWORD)
        if haspw: return
        self.timer.stop()
        (err, name) = ts3lib.getChannelVariable(schid, channelID,
                                                ChannelProperties.CHANNEL_NAME)
        if confirm(
                "Password removed",
                "Password was removed from channel \"{0}\" by \"{1}\"\n\nDo you want to join now?"
                .format(name, invokerName)):
            (err, ownID) = ts3lib.getClientID(self.schid)
            ts3lib.requestClientMove(schid, ownID, channelID, "")
        self.cracking = False

    def onDelChannelEvent(self, schid, channelID, invokerID, invokerName,
                          invokerUniqueIdentifier):
        if not self.cracking: return
        if not self.cid == channelID: return
        if not self.schid == schid: return
        self.timer.stop()
        msgBox(
            "Channel #{0} got deleted by \"{1}\"\n\nStopping Cracker!".format(
                self.cid, invokerName), QMessageBox.Warning)
        self.cracking = False

    def onServerUpdatedEvent(self, schid):
        if not self.requested: return
        self.requested = False
        self.interval = calculateInterval(
            schid, AntiFloodPoints.VERIFYCHANNELPASSWORD, self.name)

    def onConnectStatusChangeEvent(self, schid, newStatus, errorNumber):
        if newStatus == ConnectStatus.STATUS_CONNECTION_ESTABLISHED:
            self.requested = True
            ts3lib.requestServerVariables(schid)
        if newStatus == ConnectStatus.STATUS_DISCONNECTED:
            if not self.cracking: return
            if not self.schid == schid: return
            self.timer.stop()
            # (err, name) = ts3lib.getChannelVariable(schid, self.cid, ChannelProperties.CHANNEL_NAME)
            msgBox("Server left\n\nStopping Cracker!", QMessageBox.Warning)
            self.cracking = False
コード例 #7
0
ファイル: billboardtest.py プロジェクト: A-K/naali
class MyTest():
	def __init__(self):
		pass
		
	def testBillboard(self):	
		avatar = naali.getUserAvatar()
		avatar_pos = avatar.GetComponentRaw("EC_Placeable")
		
		self.pixmap_label = QLabel()
		self.pixmap_label.size = QSize(200,200)
		self.pixmap_label.scaledContents = True
		self.pixmap_label.setPixmap(QPixmap('./data/ui/images/naali_icon.png'))

		self.text_label = QLabel()
		self.text_label.size = QSize(300,50)
		self.text_label.text = "Hello world"

		self.my_widget = QWidget()
		self.my_widget.setLayout(QVBoxLayout())
		self.my_widget.layout().addWidget(self.pixmap_label)
		self.my_widget.layout().addWidget(self.text_label)
		
		if self.my_widget is None:
			print("Cannot find image file.")
			return
			
		self.my_entity = naali.createEntity()
		position = self.my_entity.GetOrCreateComponentRaw("EC_Placeable", "pos", PythonQt.private.AttributeChange.Disconnected, False)
		position.position = avatar_pos.position
		
		self.ec_billboard = self.my_entity.GetOrCreateComponentRaw("EC_BillboardWidget", "test", PythonQt.private.AttributeChange.Disconnected, False)
		if self.ec_billboard is None:
			print("Cannot create EC_Billboard component.")
			return
	
		self.ec_billboard.SetPosition(0,0,1)
		self.ec_billboard.SetWidth(1)
		self.ec_billboard.SetHeight(1)
		self.ec_billboard.SetWidget(self.my_widget)
		
		self.size_timer = QTimer()
		self.size_timer.connect("timeout()", self.animateSize)
		self.size_timer.start(100)
		 
		self.text_timer = QTimer()
		self.text_timer.connect("timeout()", self.animateText)
		self.text_timer.start(1000)
		
	def animateSize(self):
		min_width = 1.0
		max_width = 2.0
		min_height = 1.0
		max_height = 2.0
		delta_width = max_width-min_width
		delta_height = max_height-min_height
		width = min_width + 0.5*delta_width + 0.5*delta_width*math.sin(time.time()*1.324)
		height = min_height + 0.5*delta_height + 0.5*delta_height*math.cos(time.time()*2.232)
		self.ec_billboard.SetSize(width, height)
		
	def animateText(self):	
		text = str(float(time.time()))
		self.text_label.text = text
		self.ec_billboard.Refresh()
コード例 #8
0
class nowPlaying(ts3plugin):
    name = "Now Playing"
    apiVersion = 22
    requestAutoload = False
    version = "1.0"
    author = "Bluscream"
    description = "Now playing plugin in pyTSon"
    offersConfigure = True
    commandKeyword = "info"
    infoTitle = "[b]"+name+":[/b]"
    menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "Toggle Now Playing", "")]
    hotkeys = []
    ini = path.join(ts3lib.getConfigPath(), "plugins", "pyTSon", "scripts", "nowPlaying", "settings.ini")
    cfg = configparser.ConfigParser()
    cfg.optionxform = str
    timer = None
    schid = 0
    prefix = ""
    suffix = ""
    interval = 10000
    enabled = False

    def __init__(self):
        self.dlg = None
        if path.isfile(self.ini):
            self.cfg.read(self.ini)
        else:
            self.cfg['general'] = { "Debug": "False" }
            self.cfg['nowplaying'] = { "client_nickname": "{title}" }
            with open(self.ini, 'w') as configfile:
                self.cfg.write(configfile)
        # self.timer.timeout.connect(self.tick)
        if self.cfg.getboolean('general', 'Debug'):
            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 onConnectStatusChangeEvent(self, schid, newStatus, errorNumber):
        if not self.enabled: return
        if newStatus == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED:
            self.schid = schid;self.timer.start(self.interval)
        elif newStatus == ts3defines.ConnectStatus.STATUS_DISCONNECTED:
            self.schid = 0;self.timer.stop()

    def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
        if menuItemID == 0:
            if self.timer is None:
                self.timer = QTimer()
                self.timer.timeout.connect(self.tick)
            if self.timer.isActive():
                self.timer.timeout.disconnect(self.tick)
                self.timer.stop()
                self.timer = None
                del self.timer
                ts3lib.printMessageToCurrentTab('Timer stopped!')
            else:
                self.timer.start(self.interval)
                ts3lib.printMessageToCurrentTab('Timer started!')
            self.enabled = not self.enabled
            ts3lib.printMessageToCurrentTab("{0}Set {1} to [color=yellow]{2}[/color]".format(self.timestamp(),self.name,self.toggle))

    def buildString(self, value):
        return "{0}{1}{2}".format(self.prefix, value.replace('{title}',spotilib.song()).replace('{artist}',spotilib.artist()).replace('{artists}',spotimeta.artists()), self.suffix)

    def getString(self, value):
        return self.cfg.get('nowplaying', value)

    def tick(self):
        if self.getString('client_nickname') != "":
            ts3lib.setClientSelfVariableAsString(self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME, self.buildString(self.getString('client_nickname')))
            ts3lib.flushClientSelfUpdates(self.schid)

    def configDialogClosed(self, r, vals):
        try:
            ts3lib.printMessageToCurrentTab("vals: "+str(vals))
            if r == QDialog.Accepted:
                for name, val in vals.items():
                    try:
                        if not val == self.cfg.getboolean('general', name):
                            self.cfg.set('general', str(name), str(val))
                    except:
                        from traceback import format_exc
                        ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon", 0)
                with open(self.ini, 'w') as configfile:
                    self.cfg.write(configfile)
        except:
            from traceback import format_exc
            ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon", 0)

    def configure(self, qParentWidget):
        try:
            if not self.dlg:
                self.dlg = SettingsDialog(self)
            self.dlg.show()
            self.dlg.raise_()
            self.dlg.activateWindow()
        except:
            from traceback import format_exc
            ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon", 0)
コード例 #9
0
ファイル: __init__.py プロジェクト: jelidi/pyTSon_plugins
class rotateNick(ts3plugin):
    name = "Rotate Nickname"
    apiVersion = 22
    requestAutoload = False
    version = "1.0"
    author = "Bluscream"
    description = "Converts your nickname into an ugly marquee\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,
                  "Toggle rotating nickname", "")]
    hotkeys = []
    timer = None
    debug = False
    max = ts3defines.TS3_MAX_SIZE_CLIENT_NICKNAME_NONSDK
    nick = "TeamspeakUser"
    seperator = "꧂"
    schid = 0
    i = max - 2
    b = 0
    dlg = None
    ini = path.join(ts3lib.getPluginPath(), "pyTSon", "scripts", "rotateNick",
                    "config.ini")
    config = configparser.ConfigParser()

    def separator(self, sep=None):
        if sep: self.config.set('general', 'separator', sep.replace(" ", "\s"))
        else: return self.config.get('general', 'separator').replace("\s", " ")

    @staticmethod
    def timestamp():
        return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now())

    def __init__(self):
        if path.isfile(self.ini):
            self.config.read(self.ini)
        else:
            self.config["general"] = {
                "cfgver": "1",
                "debug": "False",
                "nick": "TeamspeakUser",
                "customNick": "False",
                "interval": "1000",
                "separator": " "
            }
            with open(self.ini, 'w') as configfile:
                self.config.write(configfile)

        # if self.timer is None:
        self.timer = QTimer()
        self.timer.timeout.connect(self.tick)
        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 stop(self):
        self.stopTimer()

    def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
        if menuItemID == 0:
            if hasattr(self.timer, "isActive") and self.timer.isActive():
                self.stopTimer()
            else:
                self.schid = schid
                if not self.dlg: self.dlg = dialog(self)
                self.dlg.show()
                self.dlg.raise_()
                self.dlg.activateWindow()

    def startTimer(self, interval=1000, nick=None):
        try:
            self.nick = nick
            # if len(nick) > self.max-2: errorMsgBox("Error", "Nickname must be %s chars or below!"%self.max); return
            self.i = self.max - 2
            self.b = 0
            # step = inputBox(self.name, 'Interval in Milliseconds:')
            # if step: interval = int(step)
            # else: interval = 300
            self.timer.start(interval)
            ts3lib.printMessageToCurrentTab('Timer started!')
        except:
            from traceback import format_exc
            ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR,
                              "pyTSon", 0)

    def stopTimer(self):
        if hasattr(self.timer, "isActive") and self.timer.isActive():
            self.timer.stop()
            # self.timer = None
            ts3lib.setClientSelfVariableAsString(
                self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME,
                self._nick)
            ts3lib.flushClientSelfUpdates(self.schid)
            ts3lib.printMessageToCurrentTab('Timer stopped!')

    def tick(self):
        try:
            if self.schid == 0: return
            max = self.max - 1
            _nick = list(self.nick)
            if self.i == (len(_nick) * -1) + 2:
                self.i = max
                self.b = 0
            self.i -= 1
            self.b += 1
            # ts3lib.printMessageToCurrentTab("self.i == %s | self.b == %s"%(self.i,self.b))
            count = 0
            newnick = ["!"]

            for k in range(0, self.i):
                newnick.append(self.separator())
                count += 1

            if self.i > 1:
                for k in range(0, self.b):
                    if k < len(_nick) and k < max:
                        newnick.append(_nick[k])
                        # ts3lib.printMessageToCurrentTab("1: {} | 2: {} | 3: {}".format(0, self.b, self._nick[k]))
                        count += 1
                    else:
                        pass
                #for k in range(count, max):
                #newnick.append(separator())
            else:
                for k in range(self.i * -1, len(_nick)):
                    if k != -1 and count < max:
                        newnick.append(_nick[k])
                        count += 1
                #for k in range(count, max):
                #newnick.append(self.separator())
            # newnick.append("!")
            _newnick = ''.join(newnick)
            if _newnick is None: return
            # ts3lib.printMessageToCurrentTab("length: {} | newnick: \"{}\"".format(len(_newnick), _newnick))
            ts3lib.setClientSelfVariableAsString(
                self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME,
                _newnick)
            ts3lib.flushClientSelfUpdates(self.schid)
        except:
            from traceback import format_exc
            ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR,
                              "pyTSon", 0)
コード例 #10
0
ファイル: __init__.py プロジェクト: alex720/pyTSon_plugins
class antiAFK(ts3plugin):
    name = "Anti AFK"
    apiVersion = 22
    requestAutoload = True
    version = "1.0"
    author = "Bluscream"
    description = "Never get moved by being AFK again."
    offersConfigure = False
    commandKeyword = ""
    infoTitle = None
    menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0,
                  "Toggle " + name, "")]
    hotkeys = []
    debug = False
    timer = None
    schid = 0
    clid = 0
    text = "."

    @staticmethod
    def timestamp():
        return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now())

    def __init__(self):
        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 stop(self):
        if hasattr(self.timer, "isActive") and self.timer.isActive():
            self.toggleTimer(self.schid)

    def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
        if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL and menuItemID == 0:
            self.toggleTimer(schid)

    def toggleTimer(self, schid):
        if self.timer is None:
            self.timer = QTimer()
            self.timer.timeout.connect(self.tick)
        if self.timer.isActive():
            self.timer.stop()
            self.timer = None
            ts3lib.printMessageToCurrentTab('Timer stopped!')
        else:
            self.schid = schid
            err, self.clid = ts3lib.getClientID(schid)
            self.timer.start(randint(30 * 1000, 120 * 1000))
            ts3lib.printMessageToCurrentTab('Timer started!')

    def onConnectStatusChangeEvent(self, schid, newStatus, errorNumber):
        if newStatus == ts3defines.ConnectStatus.STATUS_DISCONNECTED:
            if hasattr(self.timer, "isActive") and self.timer.isActive():
                self.toggleTimer(schid)

    def onTextMessageEvent(self, schid, targetMode, toID, fromID, fromName,
                           fromUniqueIdentifier, message, ffIgnored):
        if fromID == self.clid and targetMode == ts3defines.TextMessageTargetMode.TextMessageTarget_CLIENT and message == self.text:
            return 1

    def tick(self):
        ts3lib.requestSendPrivateTextMsg(self.schid, self.text, self.clid)
コード例 #11
0
ファイル: __init__.py プロジェクト: alex720/pyTSon_plugins
class countNick(ts3plugin):
    name = "Rotate Nickname"
    apiVersion = 22
    requestAutoload = False
    version = "1.0"
    author = "Bluscream"
    description = "Converts your nickname into an ugly marquee\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,
                  "Toggle rotating nickname", "")]
    hotkeys = []
    timer = None
    debug = False
    max = ts3defines.TS3_MAX_SIZE_CLIENT_NICKNAME_NONSDK
    nick = "TeamspeakUser"
    seperator = " "
    _nick = []
    schid = 0
    i = max - 2
    b = 0

    @staticmethod
    def timestamp():
        return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now())

    def __init__(self):
        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, selectedItemID):
        if menuItemID == 0:
            if self.timer is None:
                self.timer = QTimer()
                self.timer.timeout.connect(self.tick)
            if self.timer.isActive():
                self.timer.stop()
                self.timer = None
                ts3lib.setClientSelfVariableAsString(
                    schid, ts3defines.ClientProperties.CLIENT_NICKNAME,
                    self.nick)
                ts3lib.flushClientSelfUpdates(schid)
                ts3lib.printMessageToCurrentTab('Timer stopped!')
            else:
                (err, nick) = ts3lib.getClientSelfVariable(
                    schid, ts3defines.ClientProperties.CLIENT_NICKNAME)
                if len(nick) > self.max - 2:
                    errorMsgBox(
                        "Error",
                        "Nickname must be %s chars or below!" % self.max)
                    return
                self.nick = nick
                self._nick = list(nick)
                self.i = self.max - 2
                self.b = 0
                self.schid = schid
                step = inputBox(self.name, 'Interval in Milliseconds:')
                if step: interval = int(step)
                else: interval = 300
                self.timer.start(interval)
                ts3lib.printMessageToCurrentTab('Timer started!')

    def tick(self):
        if self.schid == 0: return
        _newnick = self.fillnick()
        if _newnick is None: return
        ts3lib.printMessageToCurrentTab("length: {} | newnick: \"{}\"".format(
            len(_newnick), _newnick))
        ts3lib.setClientSelfVariableAsString(
            self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME, _newnick)
        ts3lib.flushClientSelfUpdates(self.schid)

    def fillnick(self):
        max = self.max - 2
        if self.i == (len(self._nick) * -1):
            self.i = max
            self.b = 0
        self.i -= 1
        self.b += 1
        ts3lib.printMessageToCurrentTab("self.i == %s | self.b == %s" %
                                        (self.i, self.b))
        count = 0
        newnick = ["!"]

        for k in range(0, self.i):
            newnick.append(self.seperator)
            count += 1

        if self.i > 1:
            for k in range(0, self.b):
                if k < len(self._nick):  #k anpassen das nicht über _nick len
                    newnick.append(self._nick[k])  #((k+1)-self.max) * -1])
                    ts3lib.printMessageToCurrentTab(
                        "1: {} | 2: {} | 3: {}".format(0, self.b,
                                                       self._nick[k]))
                    count += 1
                else:
                    pass
            for k in range(count, max):
                newnick.append(self.seperator)
        else:
            for k in range(self.i * -1, len(self._nick)):
                if k == -1:
                    pass
                else:
                    newnick.append(self._nick[k])
                    count += 1
            for k in range(count, max):
                newnick.append(self.seperator)
        newnick.append("!")
        return ''.join(newnick)
コード例 #12
0
ファイル: billboardtest.py プロジェクト: etradewind/Tundra2
class MyTest():
    def __init__(self):
        pass

    def testBillboard(self):
        avatar = naali.getUserAvatar()
        avatar_pos = avatar.GetComponentRaw("EC_Placeable")

        self.pixmap_label = QLabel()
        self.pixmap_label.size = QSize(200, 200)
        self.pixmap_label.scaledContents = True
        self.pixmap_label.setPixmap(QPixmap('./data/ui/images/naali_icon.png'))

        self.text_label = QLabel()
        self.text_label.size = QSize(300, 50)
        self.text_label.text = "Hello world"

        self.my_widget = QWidget()
        self.my_widget.setLayout(QVBoxLayout())
        self.my_widget.layout().addWidget(self.pixmap_label)
        self.my_widget.layout().addWidget(self.text_label)

        if self.my_widget is None:
            print("Cannot find image file.")
            return

        self.my_entity = naali.createEntity()
        position = self.my_entity.GetOrCreateComponentRaw(
            "EC_Placeable", "pos",
            PythonQt.private.AttributeChange.Disconnected, False)
        position.position = avatar_pos.position

        self.ec_billboard = self.my_entity.GetOrCreateComponentRaw(
            "EC_BillboardWidget", "test",
            PythonQt.private.AttributeChange.Disconnected, False)
        if self.ec_billboard is None:
            print("Cannot create EC_Billboard component.")
            return

        self.ec_billboard.SetPosition(0, 0, 1)
        self.ec_billboard.SetWidth(1)
        self.ec_billboard.SetHeight(1)
        self.ec_billboard.SetWidget(self.my_widget)

        self.size_timer = QTimer()
        self.size_timer.connect("timeout()", self.animateSize)
        self.size_timer.start(100)

        self.text_timer = QTimer()
        self.text_timer.connect("timeout()", self.animateText)
        self.text_timer.start(1000)

    def animateSize(self):
        min_width = 1.0
        max_width = 2.0
        min_height = 1.0
        max_height = 2.0
        delta_width = max_width - min_width
        delta_height = max_height - min_height
        width = min_width + 0.5 * delta_width + 0.5 * delta_width * math.sin(
            time.time() * 1.324)
        height = min_height + 0.5 * delta_height + 0.5 * delta_height * math.cos(
            time.time() * 2.232)
        self.ec_billboard.SetSize(width, height)

    def animateText(self):
        text = str(float(time.time()))
        self.text_label.text = text
        self.ec_billboard.Refresh()