SkPy


NameSkPy JSON
Version 0.11 PyPI version JSON
download
home_pagehttps://skpy.t.allofti.me
SummaryAn unofficial Python library for interacting with the Skype HTTP API.
upload_time2024-09-01 09:02:06
maintainerNone
docs_urlNone
authorOllie Terrance
requires_pythonNone
licenseNone
keywords
VCS
bugtrack_url
requirements beautifulsoup4 requests
Travis-CI No Travis.
coveralls test coverage No coveralls.
            SkPy
====

An unofficial Python library for interacting with the Skype HTTP API.

Here be dragons
---------------

The upstream APIs used here are undocumented and are liable to change, which may cause parts of this library to fall apart in obvious or non-obvious ways.  You have been warned.

Requirements
------------

- Python 2.6+ (includes 3.x)
- `BeautifulSoup <http://www.crummy.com/software/BeautifulSoup/>`_
- `Requests <http://www.python-requests.org/en/latest/>`_ [1]_
- `Responses <https://github.com/getsentry/responses>`_ (for tests)

.. [1] Note that Requests no longer supports Python 3.2 -- the last working version is 2.10.0.

Getting started
---------------

The documentation gives some examples in more detail, as well as a full API specification, but here are the basics to get you started:

.. code:: python

    from skpy import Skype
    sk = Skype(username, password) # connect to Skype

    sk.user # you
    sk.contacts # your contacts
    sk.chats # your conversations

    ch = sk.chats.create(["joe.4", "daisy.5"]) # new group conversation
    ch = sk.contacts["joe.4"].chat # 1-to-1 conversation

    ch.sendMsg(content) # plain-text message
    ch.sendFile(open("song.mp3", "rb"), "song.mp3") # file upload
    ch.sendContact(sk.contacts["daisy.5"]) # contact sharing

    ch.getMsgs() # retrieve recent messages

Rate limits and sessions
------------------------

If you make too many authentication attempts, the Skype API may temporarily rate limit you, or require a captcha to continue. For the latter, you will need to complete this in a browser with a matching IP address.

To avoid this, you should reuse the Skype token where possible. A token only appears to last 24 hours (web.skype.com forces re-authentication after that time), though you can check the expiry with ``sk.tokenExpiry``. Pass a filename as the third argument to the ``Skype()`` constructor to read and write session information to that file.

Event processing
----------------

Make your class a subclass of ``SkypeEventLoop``, then override the ``onEvent(event)`` method to handle incoming messages and other events:

.. code:: python

    from skpy import SkypeEventLoop, SkypeNewMessageEvent
    class SkypePing(SkypeEventLoop):
        def __init__(self):
            super(SkypePing, self).__init__(username, password)
        def onEvent(self, event):
            if isinstance(event, SkypeNewMessageEvent) \
              and not event.msg.userId == self.userId \
              and "ping" in event.msg.content:
                event.msg.chat.sendMsg("Pong!")

Create an instance and call its ``loop()`` method to start processing events. For programs with a frontend (e.g. a custom client), you'll likely want to put the event loop in its own thread.

Tests and documentation
-----------------------

Unit tests can be found in the ``test`` folder -- client test cases are designed to test the library's behaviour and parsing of mocked API responses, whereas server cases connect to the live Skype API.

The `SkPy docs <https://github.com/OllieTerrance/SkPy.docs>`_ repo holds, in addition to docs for this library, a collection of unofficial documentation for the Skype HTTP APIs at large.

            

Raw data

            {
    "_id": null,
    "home_page": "https://skpy.t.allofti.me",
    "name": "SkPy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Ollie Terrance",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/56/92/7629810108c9cfedeb8587f566bdb7ac9a78fcf0c1a63334232a231c50db/skpy-0.11.tar.gz",
    "platform": null,
    "description": "SkPy\n====\n\nAn unofficial Python library for interacting with the Skype HTTP API.\n\nHere be dragons\n---------------\n\nThe upstream APIs used here are undocumented and are liable to change, which may cause parts of this library to fall apart in obvious or non-obvious ways.  You have been warned.\n\nRequirements\n------------\n\n- Python 2.6+ (includes 3.x)\n- `BeautifulSoup <http://www.crummy.com/software/BeautifulSoup/>`_\n- `Requests <http://www.python-requests.org/en/latest/>`_ [1]_\n- `Responses <https://github.com/getsentry/responses>`_ (for tests)\n\n.. [1] Note that Requests no longer supports Python 3.2 -- the last working version is 2.10.0.\n\nGetting started\n---------------\n\nThe documentation gives some examples in more detail, as well as a full API specification, but here are the basics to get you started:\n\n.. code:: python\n\n    from skpy import Skype\n    sk = Skype(username, password) # connect to Skype\n\n    sk.user # you\n    sk.contacts # your contacts\n    sk.chats # your conversations\n\n    ch = sk.chats.create([\"joe.4\", \"daisy.5\"]) # new group conversation\n    ch = sk.contacts[\"joe.4\"].chat # 1-to-1 conversation\n\n    ch.sendMsg(content) # plain-text message\n    ch.sendFile(open(\"song.mp3\", \"rb\"), \"song.mp3\") # file upload\n    ch.sendContact(sk.contacts[\"daisy.5\"]) # contact sharing\n\n    ch.getMsgs() # retrieve recent messages\n\nRate limits and sessions\n------------------------\n\nIf you make too many authentication attempts, the Skype API may temporarily rate limit you, or require a captcha to continue. For the latter, you will need to complete this in a browser with a matching IP address.\n\nTo avoid this, you should reuse the Skype token where possible. A token only appears to last 24 hours (web.skype.com forces re-authentication after that time), though you can check the expiry with ``sk.tokenExpiry``. Pass a filename as the third argument to the ``Skype()`` constructor to read and write session information to that file.\n\nEvent processing\n----------------\n\nMake your class a subclass of ``SkypeEventLoop``, then override the ``onEvent(event)`` method to handle incoming messages and other events:\n\n.. code:: python\n\n    from skpy import SkypeEventLoop, SkypeNewMessageEvent\n    class SkypePing(SkypeEventLoop):\n        def __init__(self):\n            super(SkypePing, self).__init__(username, password)\n        def onEvent(self, event):\n            if isinstance(event, SkypeNewMessageEvent) \\\n              and not event.msg.userId == self.userId \\\n              and \"ping\" in event.msg.content:\n                event.msg.chat.sendMsg(\"Pong!\")\n\nCreate an instance and call its ``loop()`` method to start processing events. For programs with a frontend (e.g. a custom client), you'll likely want to put the event loop in its own thread.\n\nTests and documentation\n-----------------------\n\nUnit tests can be found in the ``test`` folder -- client test cases are designed to test the library's behaviour and parsing of mocked API responses, whereas server cases connect to the live Skype API.\n\nThe `SkPy docs <https://github.com/OllieTerrance/SkPy.docs>`_ repo holds, in addition to docs for this library, a collection of unofficial documentation for the Skype HTTP APIs at large.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "An unofficial Python library for interacting with the Skype HTTP API.",
    "version": "0.11",
    "project_urls": {
        "Download": "https://github.com/Terrance/SkPy/releases",
        "Homepage": "https://skpy.t.allofti.me"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d409d3f87de1dd8808300d059427ea8ceec3013678fc3bbf1c51cd075b704c19",
                "md5": "41f418dfd99a5919d86ab57d9d875a95",
                "sha256": "26f71581b328e6e72e47f8f3b76b0ea2165a7e5543a56b86f065f42cab948191"
            },
            "downloads": -1,
            "filename": "SkPy-0.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "41f418dfd99a5919d86ab57d9d875a95",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 49269,
            "upload_time": "2024-09-01T09:02:04",
            "upload_time_iso_8601": "2024-09-01T09:02:04.794592Z",
            "url": "https://files.pythonhosted.org/packages/d4/09/d3f87de1dd8808300d059427ea8ceec3013678fc3bbf1c51cd075b704c19/SkPy-0.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "56927629810108c9cfedeb8587f566bdb7ac9a78fcf0c1a63334232a231c50db",
                "md5": "251d3977d9ab6c43c0f2ea5eaf9f98b2",
                "sha256": "37071b159827c36585ec170ecaac233c221f4dcd06851f12c1fd20579f02769e"
            },
            "downloads": -1,
            "filename": "skpy-0.11.tar.gz",
            "has_sig": false,
            "md5_digest": "251d3977d9ab6c43c0f2ea5eaf9f98b2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 53387,
            "upload_time": "2024-09-01T09:02:06",
            "upload_time_iso_8601": "2024-09-01T09:02:06.569509Z",
            "url": "https://files.pythonhosted.org/packages/56/92/7629810108c9cfedeb8587f566bdb7ac9a78fcf0c1a63334232a231c50db/skpy-0.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-01 09:02:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Terrance",
    "github_project": "SkPy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "beautifulsoup4",
            "specs": []
        },
        {
            "name": "requests",
            "specs": []
        }
    ],
    "lcname": "skpy"
}
        
Elapsed time: 0.28667s