Forum


Notice to all users

We are migrating towards a new forum system located at community.teamspeak.com, as such this forum will become read-only on January 29, 2020

Page 1 of 4 123 ... LastLast
Results 1 to 15 of 51
  1. #1
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376

    [RELEASE] pyTSon - A python plugin

    pyTSon

    **CAUTION** This is currently alpha software, so it can (and I guess, it will!) crash your client. Callbacks and ts3lib functions need to be tested. So please don't bomb TeamSpeak Systems with crashdumps if you are using this plugin.

    pyTSon is a Python plugin for your TeamSpeak 3 client. It offers a python3 (current used version is Python 3.5.7) interface for the plugin sdk. This plugin makes your client scriptable, react on events or write your subroutines callable by hotkeys or from the client's menu.


    Batteries included
    Did I miss the lua plugin? No, I didn't. The advantage of pyTSon is, that all ts3lib functions the pluginsdk offers are wrapped and all callbacks are accessible (see "What is missing?" down below for some exceptions).
    The creation process of a script is much easier, just create a new file with your plugin-class in scripts/ and you are done.

    The python standard library is included, either built in the plugin or bundled in include/Lib (which is in sys.path by default). pyTSon has PythonQt included, so that scripts can have UIs written in python, see pyTSon's own configdialog or the scripting console for examples (includes/pytsonui.py). So Qt classes are wrapped into the PythonQt.* modules and there is no external dependency, the TeamSpeak 3 client's Qt libraries are used (so don't create a new QApplication object, the client ones is used!). See http://pythonqt.sourceforge.net/Developer.html for more info on using PythonQt in your scripts.
    But be carefull! If you mess up with some internals (like QApplication or Qt's eventloop), you might crash your client. Safest way to be sure, that objects are cleared, is to set the WA_DeleteOnClose attribute on your dialogs or widgets or such.


    How do I write a plugin?
    Here is a small example plugin:
    Code:
    from ts3plugin import ts3plugin
    
    import ts3lib, ts3defines
    
    class testplugin(ts3plugin):
        name = "test"
        requestAutoload = False
        version = "1.0"
        apiVersion = 21
        author = "Thomas \"PLuS\" Pathmann"
        description = "This is a testplugin"
        offersConfigure = True
        commandKeyword = ""
        infoTitle = ""
        menuItems = []#[(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT, 0, "text", "icon.png")]
        hotkeys = []#[("keyword", "description")]
    
        def __init__(self):
            ts3lib.printMessageToCurrentTab("Yay, we are running!")
    
        def stop(self):
            ts3lib.printMessageToCurrentTab("Oh no, we were stopped :(")
    
        def onNewChannelEvent(self, schid, channelID, channelParentID):
            err, name = ts3lib.getChannelVariableAsString(schid, channelID, ts3defines.ChannelProperties.CHANNEL_NAME)
            if err == ts3defines.ERROR_ok:
                ts3lib.printMessageToCurrentTab("new channel %s" % name)
            else:
                ts3lib.printMessageToCurrentTab("got error %s" % err)
    Just create a subclass of ts3plugin and create any callback you wanna react to as method of your class. The 11 class attributes (name, requestAutoload, ..., hotkeys) are needed, otherwise pyTSon refuses to load your script. Your plugin is loaded as a python plugin, so create a subdirectory in the scripts folder.
    If you are familiar with the C pluginsdk, you'll get the idea. Otherwise look at docs/pyTSon.pdf or https://pytson.4qt.de for a full list of functions and callbacks (docs are mostly not filled with content, but all functions and callbacks are at least listed with their parameters, I'm working on that).


    Includes
    Already got a python module you wanna use in your TeamSpeak client? No problem: place it in your plugin subdirectory and use relative imports.
    Plugins installed from a repository can also give dependencies from the python package index which are installed to the include directory (which is in sys.path by default).


    What is missing?
    • Callbacks like ts3plugin_name, ts3plugin_author and such are not wrapped as functions, instead they must be added as class attributes of your python plugin.
    • Some callbacks like ts3plugin_setFunctionPointers or ts3plugin_freeMemory, because you don't need them. All memory management is done by the plugin itsself.
    • The callbacks onEditPlaybackVoiceDataEvent, onEditPostProcessVoiceDataEvent, onEditMixedPlaybackVoiceDataEvent, onEditCapturedVoiceDataEvent, onCustom3dRolloffCalculationClientEvent, onCustom3dRolloffCalculationWaveEvent, onFileTransferStatusEvent and onUserLoggingMessageEvent are not wrapped. They are called from a different thread than the other callbacks and that would require some thread safety measures.
    • Threading. You can't use any python threading methods. Write a c plugin instead.



    Downloads
    You can get builds from here: https://github.com/pathmann/pyTSon/releases

    For additional information, visit the github page: https://github.com/pathmann/pyTSon

    pyTSon is released under the GPL.
    If you find any bugs, please open a new issue on the github page. If you don't know, in which callback the client crashes, add a print(name) in PluginHost.callMethod and start your client from the commandline (linux) or start your client with -console (windows).
    Last edited by Thomas; January 27th, 2017 at 03:44 PM. Reason: There is a mac build now; added windows note; updated used python version; updated infos to v1.1.0 release

  2. #2
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    Some demo plugins are available here: https://github.com/pathmann/pyTSon_plugins

  3. #3
    Join Date
    October 2003
    Location
    Germany
    Posts
    2,527
    Quote Originally Posted by Thomas View Post
    Some demo plugins are available here: https://github.com/pathmann/pyTSon_plugins
    Awesome stuff! I like the tweakui example.


  4. #4
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    Added version 1.0.1.

    Changelog:
    • python is now linked shared
    • using python 3.5.2
    • infoData will now work as intended
    • the settingsbutton will now be enabled/disabled accordingly
    • after reloading, all previously running plugins are started again
    • plugins are sorted by name in configdialog
    • menus and hotkeys are working now
    • fixed a crash, when configdialog and/or shell are opened while reloading pyTSon
    • and some other minor fixes


    You need to delete the directory <TeamSpeak 3 client install dir>/plugins/pyTSon/include/Lib of a previous installation.

    If 1.0.0 does not work for you (on windows), please recheck with this version (linking libraries on Windows is really strange ).

    See the Releases on github for Downloads.

  5. #5
    Join Date
    June 2008
    Location
    -
    Posts
    252
    Delicious :P

  6. #6
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    Added version 1.0.2

    Changelog:
    • Added a mac build
    • Updated to api version 21 (Client Version 3.1 beta)
    • Updated to Qt 5.6.1 (but only Core, Gui, Widgets, Network, Sql and UITools modules are wrapped, more to come later)
    • On Linux and Mac, the python lib is loaded from the plugin directory (on Windows, you still have to move the lib to the client install root)
    • include/Lib has now a architecture suffix on Linux and Windows (this is necessary, if you have both client architectures installed)
    • Fixed pos1/home key button in scripting console
    • Fixed a false indentation on tabcomplete in scripting console
    • Added function ts3.getPluginID (there are no real use-cases for this, because the plugin id is not needed to call api functions from python)


    You should delete old files from a previous installation of pyTSon (backup your scripts first).

    See the release on github for Downloads.

  7. #7
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    Added version 1.0.3

    Changelog:
    • Removed callbacks ts3plugin_onCustom3dRolloffCalculationWaveEvent and ts3plugin_onCustom3dRolloffCalculationClientEvent (as long as pyTSon can't handle callbacks from other threads than the main one)
    • Configuration window now raises, if already exist and clicked again in menu


    You should delete old files from a previous installation of pyTSon (backup your scripts first).

    See the release on github for Downloads.

  8. #8
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    Added version 1.0.4

    Changelog:
    • added some example plugins (see the scripts directory)
    • empty infoData will be ignored from now on, you should set infoTitle to None, if your script does not show any infoData
    • all python plugin code is now wrapped in try-except-blocks (exceptions in clientlog)
    • added pytsonui.getValues as convenience function to add simple configdialogs (recommended way is still to create dialogclasses)
    • hotkeys and menuitems are now reloaded, if the plugin or all plugins are reloaded
    • plugins are now reloaded, even if they offer a menuitem and/or hotkey
    • quintptr is now registered as metatype (eg. for use with internalIDs in QAbstractItemModels)
    • QAbstractItemModel/QModelIndex can now contain QObject-based objects as internalPointer (classic Qt type is void*)
    • bundle contains docs as pdf now


    You should delete old files from a previous installation of pyTSon (backup your scripts first).

    See the release on github for Downloads.

  9. #9
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    Added version 1.0.5

    Changelog:
    • removed onUserLoggingMessageEvent, onFileTransferStatusEvent (they are called from another thread, so this will help stabilizing pyTSon)
    • requestAutoload is now required for all plugins to be loaded
    • added a ts3help module which inculdes a help(obj) function, which displays help information on obj, especially if obj is a ts3 function
    • you can now check in your ts3 client, if there is a newer release on my github release page
    • pytsonui.setupUi can now handle all childwidgets (instead of passing a list of tuples), check the docstring for more information
    • pytsonui functions are now in pyTSon's documentation
    • reworked configdialog (switched to a grid layout)
    • added an ipcplugin to communicate with other applications
    • ScriptingConsole:
      • tabcompletion works now with other splitting characters than just spaces
      • you can now specify a startup script
      • the buttons in settingsdialog should now be colorized correctly


      And many other minor changes.


    You should delete old files from a previous installation of pyTSon (backup your scripts first).

    See the release on github for Downloads.

  10. #10
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    Added version 1.1.0

    Caution: The directory structure changed, see the upgrade tips at the end!

    Changelog:
    • the ts3 module got renamed to ts3lib (to not clash with packages on pypi)
    • users can now download plugins from online repositories within the app
    • plugin developers can maintain their own repository (recommended) or merge directly into the "pyTSon master" (more infos on repositories can be found here: https://github.com/pathmann/pyTSon_r...ster/README.md)
    • new plugin method "menuCreated" which is called, if the menuItems were set up
    • you can now decide to load menus from disabled plugins on startup, so you don't have to restart pyTSon when activating a plugin with menus
    • added github octicons iconpack
    • added icons to pyTSon's menuitems
    • the documentation was heavily updated, check the pdf in the docs directory or https://pytson.4qt.de
    • plugins are no longer restricted to consist of only one file, instead every plugin should be a python package in pyTSon/scripts (if your plugin is one file: create a directory, move your script into it and rename it to __init__.py); repositories can contain zipfiles which will be extracted in the app on installation (if you don't use the pypi-dependency feature of the repository and you want to deliver dependencies in your package, use relative imports instead of adding your local include directory to sys.path)
    • pip is now used for dependency handling
    • added an interpreter (no interactive mode)
    • Plugin infrastructure overhauled:
      • the python standard library is now located in pyTSon/lib/python3.5
      • pyTSon/include can be seen as a local sitepack dir
      • plugins are now python packages in pyTSon/scripts (each plugin in a subdirectory)
      • interpreter python(.exe) added in pyTSon/ (won't run from other directory!)
    • added a simple api to query the TeamSpeak 3 client's settings database with ts3client.Config
    • added api to work with IconPacks with ts3client.IconPack
    • setupUi (and others) will now load icons from an iconpack if widgets contain a dynamic string property called 'pytsonicon' containing the variable to the icon in the iconpack, instead you can use a string like "octicons:filename.png" which sets filename.png from the bundled octicons pack as icon
    • config moved to subdirectory ~/.ts3client/pyTSon; if plugins use configfiles, they should also use this directory (you can use python.getConfigPath("myconfigname.conf"), which will join the pathes accordingly)
    • added convenience functions getConfigPath and getPluginPath (in module pytson) which work like os.path.join with the specific ts3 path prefixed before
    • users can now remove plugins within the ui of the app
    • if a new version (of the python standard library) is installed, the old one will be removed automatically
    • as a result of the above, it is not longer supported to have multiple releases installed (for multiple architectures)
    • the example scripts are no longer contained in the install package but can be pulled from the "pyTSon master" repository
    • pytsonui.getValues is dropped, plugin developers need to create their own dialog classes
    • it's no longer supported to run two architecture versions of pyTSon simultaneously (on Linux and Windows, if your plugins are installed to your home/appdata directory


    And many other minor changes.

    Upgrade tips (adapt the pathes depending on your platform):
    • backup everything in ~/.ts3client/plugins/pyTSon/scripts (except ts3plugin.py)
    • backup your config files, at last pyTSon's config in ~/.ts3client/pyTSon.conf
    • wipe everything in ~/.ts3client/plugins/pyTSon
    • install release 1.1.0
    • copy the config file(s) to ~/.ts3client/pyTSon (mkdir first or start the client once and close again)
    • create a directory for each of your scripts under ~/.ts3client/plugins/pyTSon/scripts, move each script in their subdirectory and rename them to __init__.py or do other pythonic package management



    See the release on github for Downloads.

  11. #11
    Join Date
    August 2013
    Location
    Germany
    Posts
    541
    I just wanted to ask if there is already a ETA for the myTeamspeak release. Did they increase the max filesize or can you reduce the size of the .ts3_plugin package? It would make it easier for users to get the latest version. Also it would make it more trustworthy for users that can't read source code. :3

  12. #12
    Join Date
    August 2013
    Location
    Germany
    Posts
    541
    Quote Originally Posted by ScP View Post
    Awesome stuff! I like the tweakui example.

    https://www.myteamspeak.com/addons/5...c-cfe3ce4dc127

  13. #13
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    Quote Originally Posted by Bluscream View Post
    I just wanted to ask if there is already a ETA for the myTeamspeak release. Did they increase the max filesize or can you reduce the size of the .ts3_plugin package? It would make it easier for users to get the latest version.
    Not yet. I could imagine some reduced t3plugin package, but that would a) require some patches and b) then I would change it in a way, that myteamspeak is almost completely bypassed by livepatching the python part (you'd get only the C++ core library and the python lib from myteamspeak, everything else is downloaded/updated on startup). I'm not sure, if that's ok with the myteamspeak conditions or if pyTSon would get rejected because of that!?

    Quote Originally Posted by Bluscream View Post
    Also it would make it more trustworthy for users that can't read source code. :3
    I don't see the point. How is it more trustworthy, if you only receive compiled binaries? Now, you download the compiled binaries from github too, but you can easily look at the code (ofc if you want to and are able to). No offence, but imho github is a more trustworthy place than myteamspeak.

  14. #14
    Join Date
    April 2014
    Location
    Seattle, WA, USA
    Posts
    141
    First off, thank you very much for an awesome plugin. I love how you've implemented it, especially the repo system!

    I'm working on a couple of modules (scripts) for pyTSon, but I have a few questions:
    (I apologize in advance if there is a more appropriate thread for this reply, please feel free to move there if so!)

    1) How (or is it possible) to create nested UI menus?
    I searched as best I could through the github sources, all example scripts seem to use single item in ts3plugin.menuItems.

    Most likely menuItems isn't built recursively. In which case, would it be hard to add this feature?
    Maybe nested lists would allow for submenu, ordered by list append order, etc, e.g.:
    Code:
    menuItems = [(0, 1, 'TestPlugin', ''), [(0, 1.1, 'First SubMenu', ''), (0, 1.2, 'Second SubMenu', '')]]  # or maybe childMenuItems attribute?
    Or maybe have (str) dotpath for id instead of (int), e.g:
    Code:
    menuItems = [(0, 1, 'TestPlugin', ''), (0, 1.1, 'First SubMenu', ''), (0, 1.2, 'Second SubMenu', '')]
    2) When testing using ClientQuery over telnet, I ran into issues with client flood protection.
    Do plugins have any kind of flood protection or throttling?
    Is there a way to whitelist or disable flood protection for ClientQuery?
    I couldn't find any documentation regarding this anywhere...

    Thank you again for your time in developing pyTSon, it seems like a great project and I'm excited to see what I can do with it!
    Last edited by Ronin Design; April 14th, 2017 at 11:17 PM. Reason: Formatting

  15. #15
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    1) That's currently not possible. The TS3 client's plugin sdk brings this restriction. Each plugin has one menu with one level of submenus. Which means, pyTSon has one menu and every python plugin can add submenus to this. I thought about adding the menus myself (with the possibilities of the Qt framework), but this is a) a little hacky and b) is easy for the mainmenu, but not that easy for the contextmenus in the serverview tree. But looking again into this is already on my todo.

    2) As fas as I know, you'd need to grant the permission b_client_ignore_antiflood to your client or servergroup to prevent antiflood actions against your client.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [RELEASE]Now Playing Plugin
    By Screech in forum Client Plugins / Lua Scripts
    Replies: 236
    Last Post: February 3rd, 2018, 02:59 AM
  2. [Release] VLC Mute Plugin
    By SilentStorm in forum Client Plugins / Lua Scripts
    Replies: 18
    Last Post: April 30th, 2017, 09:20 PM
  3. [Release]LoLRandomizer Plugin
    By mJrA83 in forum Client Plugins / Lua Scripts
    Replies: 17
    Last Post: January 13th, 2015, 05:06 PM
  4. [Release] AutoAway plugin
    By plamen in forum Client Plugins / Lua Scripts
    Replies: 30
    Last Post: March 14th, 2014, 09:05 PM
  5. [RELEASE] Another TS3 Overlay Plugin
    By MarkR in forum Client Plugins / Lua Scripts
    Replies: 120
    Last Post: January 14th, 2011, 08:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •