Coder Social home page Coder Social logo

terrance / skpy Goto Github PK

View Code? Open in Web Editor NEW
262.0 20.0 65.0 504 KB

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

Home Page: https://skpy.t.allofti.me

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%
skype communication python

skpy's Introduction

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

[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:

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:

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 repo holds, in addition to docs for this library, a collection of unofficial documentation for the Skype HTTP APIs at large.

skpy's People

Contributors

amxtaut avatar codeofdusk avatar crazylionheart avatar galexant avatar idmedia avatar kingprapop avatar leandr92 avatar mhorst314 avatar neodymium001 avatar rcw679 avatar terrance avatar theamm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

skpy's Issues

Error with ch.sendMsg

ch.sendMsg("Salut !")
Traceback (most recent call last):
File "", line 1, in
File "skpy\chat.py", line 157, in sendMsg
return self.sendRaw(editId=edit, messagetype=msgType, content=content, skypeemoteoffset=meOffset)
File "skpy\chat.py", line 110, in sendRaw
clientTime = int(clientDate.timestamp() * 1000)
AttributeError: 'datetime.datetime' object has no attribute 'timestamp'

Live Account Not Working

I'm trying to help my friend run a Skype bot. It turns out that sometime around three months ago, Microsoft changed Skype and the website to only allow the creation of live accounts. When trying to sign into such an account via SkPy, it throws an error stating that the account doesn't exist, even though it's possible to sign into it through web Skype.

We're just using the standard ping/pong snippet from the docs, which is working for me for a normal Skype account with its own username. Here is the error:

skpy.core.SkypeAuthException: (u"That Microsoft account doesn't exist. Enter a different account or get a new one.", <Response [200]>)

I get the same error running it from my system. Are live accounts broken right now in SkPy? I checked through the issues and couldn't find any way around this.

Delete or edit throws exception

Following exception is thrown on edit or delete call even if the message content is present.
Traceback (most recent call last):
File "C:\Python35\lib\site-packages\skpy\chat.py", line 370, in getitem
return super(SkypeChats, self).getitem(key)
File "C:\Python35\lib\site-packages\skpy\core.py", line 138, in getitem
return self.cache[key]
KeyError: None

Consider renaming the project

There's already a skypy package on PyPI. Looks like there's another Skype library going by skypy too.

If it gets to the stage of publishing this module, it will need a unique name.

Names thought of so far:

  • BlueSky (blue-sky is already a thing though)
  • PySky (already exists)
  • Skyth / Skythe
  • Skython
  • SkPy

Looks like it's going to be SkPy, though sadly it loses the nice "sky" pronounceability.

"SkypeApiException: 404 response from PUT" on init

Hi! First of all, great project, thank you!
I have written a script that sends messages using SkPy. There are around 50 microsoft live accounts that work well and good.
However, there is one account, insignificant in any way, that raises error on this line :
sk = Skype(login, pass)
Where login is "@hotmail.com" . (btw, this non-working one is @outlook.com)
Full Traceback:

File "C:\Python27\Lib\site-packages\skpy\main.py", line 69, in init
self.conn.getSkypeToken()
File "C:\Python27\Lib\site-packages\skpy\conn.py", line 263, in getSkypeToken
self.liveLogin(user, pwd)
File "C:\Python27\Lib\site-packages\skpy\conn.py", line 362, in liveLogin
self.getRegToken()
File "C:\Python27\Lib\site-packages\skpy\conn.py", line 423, in getRegToken
endpoint.config()
File "C:\Python27\Lib\site-packages\skpy\conn.py", line 867, in config
"version": "908/1.30.0.128"}})
File "C:\Python27\Lib\site-packages\skpy\conn.py", line 216, in call
raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code,
method, url), resp)
skpy.core.SkypeApiException: ('404 response from PUT https://client-s.gateway.me
ssenger.live.com/v1/users/ME/endpoints/bee77efb-7a06-692a-aafd-97a003fd126c/pres
enceDocs/messagingService', <Response [404]>)

Response body is
{"errorCode":729,"message":"You must create an endpoint before performing this o peration."}

401 on SkypeImageMsg.fileContent

When I try to get the fileContent of a SkypeImageMsg or SkypeFileMsg, I get this response

 [traceback details in my own app]
 File "/usr/local/lib/python3.5/dist-packages/skpy/msg.py", line 498, in fileContent
    auth=SkypeConnection.Auth.Authorize).content
  File "/usr/local/lib/python3.5/dist-packages/skpy/conn.py", line 215, in __call__
    raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
 skpy.core.SkypeApiException: ('401 response from GET https://api.asm.skype.com/v1/objects/0-eus-d2-9fc51dfcc7c37f83eac51aa51031ceb3/views/imgpsh_fullsize', <Response [401]>)

I'm not sure what to do about this. Is it the wrong authentication method?

Any change in authentication

Hi Ollie, thanks for the wonderful library. It works like charm.
Any change happened in the login module...getting following error since few hours.

File "C:\Python35\lib\site-packages\skpy\main.py", line 68, in init
self.conn.readToken()
File "C:\Python35\lib\site-packages\skpy\conn.py", line 297, in readToken
raise SkypeAuthException("No token file specified")
skpy.conn.SkypeAuthException: No token file specified

Investigate server-side bots

Bot users have appeared in the official clients on Windows, Android and iOS.

Add a bot

They appear to have user thread identifiers beginning 28:, similar to the concierge user.

Known bots so far:

  • Skype (broadcast channel): 28:concierge
  • Murphy: 28:df682d20-8e5b-4e4a-a283-cb59cd14cbd7
  • Bing Music - Preview: 28:71995191-9d5c-4ffd-b0c3-44863de8c2df
  • Bing Images - Preview: 28:79eaad73-f046-4720-9bba-3a2c8e1b0e0b
  • Summarize: 28:deac2ccb-5a43-4d59-82fb-f75d1cc95ec0
  • Getty Images - Preview: 28:8cfad58b-15bc-42e8-bfb7-7abcb9581415

Contact list

There's no way to start a bot conversation from Skype for Web, though they will appear if you talk from elsewhere, which reveals some limited UI in place for them:

Bot disclaimer

When talking with the bot, messages you send appear to come from your Messenger identity thread, i.e. 1:<email> rather than 8:<username>. Not sure how this works on Skype-only accounts without a Microsoft/Messenger connection.

event.msg.plain() yields TypeError: 'str' object is not callable

Hey there,

I have recently updated my skpy from 0.6 to 0.7 and I started running into this problem.
I'm using Python 3.6.0.

2017-03-06 07:47:06,102 - ERROR - Exception
Traceback (most recent call last):
  File "./run.py", line 22, in onEvent
    logging.debug("text.plain(): " + str(text.plain()))
TypeError: 'str' object is not callable

I'm basically trying to use event.msg.plain() (text = event.msg) in onEvent in a SkypeEventLoop and it fails with a really weird error message.

By adding some debug output to msg.py I was able to verify that plain() is executed completely without any issues, however, it's beyond my understanding where this error could originate.

For now I have downgraded back to 0.6 since that version is working fine for me.

SkypeMsg.plain isn't stripping quote tags

I get this:

<quote author="lopezloo" authorname="lopez" conversation="#lopezloo/$*T;somenumber" guid="censored" timestamp="1492886668"><legacyquote>[08:44:28 PM] lopez: </legacyquote>a message<legacyquote>

<<< </legacyquote></quote>a comment

Message sent from Windows client (7.35.0.101).

Callback working but posting message on response fails with 404

Callback working but posting message on response fails with 404

Account type

Live (Microsoft) Account

Conversation details

1 to 1 conversation (response part to a received message)

Steps to reproduce

I use your plain vanilla example from the doc for callback:

class SkypePing(SkypeEventLoop):
    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!")

Subscription works perfectly, I send a "ping" message to the skype account, it captures it.

Then on: event.msg.chat.sendMsg("Pong!"), it fails with
SkypeApiException: ('404 response from GET https://db5-client-s.gateway.messenger.live.com/v1/users/ME/conversations/2:xxxxxxxx', <Response [404]>)

The trace (below) show the reason for this 404 is the conversation is not found.
interrestingly enough, in the receipt acknoledging the start of the conversation (the ping) the conversation link is u'https://db5-client-s.gateway.messenger.live.com/v1/users/ME/conversations/2:xxxxxxxxxxxxxx' where xxxxxxxxx is in fact [email protected].
Later, in the "pong" being sent the conversation the url is : https://db5-client-s.gateway.messenger.live.com/v1/users/ME/conversations/2:xxxxxxxxxxxxxx' where xxxxxxxxx is this time xxxxxxxxx (without the @yyyy.com). Could it be that?

Result or traceback

                 u'resource': {u'ackrequired': u'https://db5-client-s.gateway.messenger.live.com/v1/users/ME/conversations/ALL/messages/1492900657077/ack',
                               u'composetime': u'2017-04-22T22:37:37.077Z',
                               u'content': u'ping',
                               u'contentformat': u'FN=MS%20Shell%20Dlg; EF=; CO=0; CS=0; PF=0',
                               u'conversationLink': u'https://db5-client-s.gateway.messenger.live.com/v1/users/ME/conversations/2:xxxxxxxxxxxxxx',
                               u'from': u'https://db5-client-s.gateway.messenger.live.com/v1/users/ME/contacts/2:xxxxxxxxxxxxx',
                               u'id': u'1492900657077',
                               u'isactive': False,
                               u'messagetype': u'Text',
                               u'originalarrivaltime': u'2017-04-22T22:37:37.077Z',
                               u'origincontextid': u'0',
                               u'type': u'Message',
                               u'version': u'1492900657077'},
                 u'resourceLink': u'https://db5-client-s.gateway.messenger.live.com/v1/users/ME/conversations/2:xxxxxxxxxxxx/messages/1492900657077',
                 u'resourceType': u'NewMessage',
                 u'time': u'2017-04-22T22:37:37Z',
                 u'type': u'EventMessage'}]}
<= [23/04 00:37:37] GET https://db5-client-s.gateway.messenger.live.com/v1/users/ME/conversations/2:xxxxxxxx
{'params': {'view': 'msnp24Equivalent'}}
=> [23/04 00:37:37] 404
{'Cache-Control': 'no-store, must-revalidate, no-cache',
 'Content-Length': '67',
 'Content-Type': 'application/json; charset=utf-8',
 'ContextId': 'tcid=1119067422058744749,server=DB5SCH101121543',
 'Date': 'Sat, 22 Apr 2017 22:37:37 GMT',
 'Pragma': 'no-cache',
 'StatusText': 'Failure due to: ConversationNotFound.'}
{u'errorCode': 730, u'message': u'Failure due to: ConversationNotFound.'}

FileMessage fails with empty content

I think this message was edited/deleted.

SkypeImageMsg(id='14829808000', type='RichText/UriObject', time=datetime.datetime, clientId='900182', userId='blarp', chatId='8:blurp', content='')

The raw dict for it is:

{'version': '1482980188000', 'type': 'Message', 'originalarrivaltime': '2016-12-29T02:56:28.003Z', 'from': 'https://bn2-client-s.gateway.messenger.live.com/v1/users/ME/contacts/', 'content': '', 'skypeeditedid': '9002182', 'composetime': '2016-12-29T02:56:28.003Z', 'messagetype': 'RichText/UriObject', 'id': '1482980188000', 'conversationLink': 'https://bn2-client-s.gateway.messenger.live.com/v1/users/ME/conversations/'}

calling html on it results in

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/SkPy-0.0.0-py3.5.egg/skpy/msg.py", line 502, in html
AttributeError: 'NoneType' object has no attribute 'urlFull'

Receiving messages older than 30 days

Hi Ollie, I see that when we repeatedly call getMsgs(), it gets messages only for last 30 days. Is there a way to specify the duration (start and end dates) for which the messages can be returned?

SkypeCallMessage html bug

Calling html on a call message leads do this error:

  File "/usr/local/lib/python3.5/dist-packages/SkPy-0.0.0-py3.5.egg/skpy/msg.py", line 556, in html
  File "/usr/local/lib/python3.5/dist-packages/SkPy-0.0.0-py3.5.egg/skpy/msg.py", line 18, in makeTag
  File "/usr/local/lib/python3.5/dist-packages/bs4/element.py", line 911, in string
    self.append(string.__class__(string))
  File "/usr/local/lib/python3.5/dist-packages/bs4/element.py", line 378, in append
    self.insert(len(self.contents), tag)
  File "/usr/local/lib/python3.5/dist-packages/bs4/element.py", line 346, in insert
    new_childs_last_element = new_child._last_descendant(False)
AttributeError: 'Name' object has no attribute '_last_descendant'

I fixed it by adding a str call to that line of html(), ie:

conTag.append(makeTag("name", str(user.name)))

404 when calling setPresence + no endpoints returned

I'm consistently getting 404s on a machine running the library - to the extent I modified my code to not call setPresence. Here's one of the error occurrences:

Traceback (most recent call last):
  File "/opt/nagbot/code/run_bot.py", line 54, in <module>
    chat_id=chat_id
  File "/opt/nagbot/code/skype_bot/nagbot.py", line 14, in __init__
    super().__init__(user=username, pwd=password, tokenFile=token_file, autoAck=auto_ack)
  File "/opt/nagbot/venv/lib64/python3.5/site-packages/skpy/main.py", line 183, in __init__
    super(SkypeEventLoop, self).__init__(user, pwd, msEmail, msPwd, tokenFile)
  File "/opt/nagbot/venv/lib64/python3.5/site-packages/skpy/main.py", line 70, in __init__
    self.conn.getSkypeToken()
  File "/opt/nagbot/venv/lib64/python3.5/site-packages/skpy/conn.py", line 262, in getSkypeToken
    self.login(user, pwd)
  File "/opt/nagbot/venv/lib64/python3.5/site-packages/skpy/conn.py", line 404, in login
    self.getRegToken()
  File "/opt/nagbot/venv/lib64/python3.5/site-packages/skpy/conn.py", line 543, in getRegToken
    self.endpoints["main"].config()
  File "/opt/nagbot/venv/lib64/python3.5/site-packages/skpy/conn.py", line 601, in config
    "version": "908/1.30.0.128"}})
  File "/opt/nagbot/venv/lib64/python3.5/site-packages/skpy/conn.py", line 215, in __call__
    raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
skpy.core.SkypeApiException: ('404 response from PUT https://client-s.gateway.messenger.live.com/v1/users/ME/endpoints/2b9857e1-c9cb-4c78-9b94-b59a5d46c7f4/presenceDocs/messagingService', <Response [404]>)

One other thing I did notice is that the return from the

endpointResp = self("POST", "{0}/users/ME/endpoints".format(self.msgsHost), codes=(200, 201, 404),
                    headers=headers, json={"endpointFeatures": "Agent"})

call, on skpy/conn.py, lines 520-521, does not contain any data, and then the subsequent call to endpointResp.json() returns []. This breaks self.endpoints["main"] = SkypeEndpoint(self, endpointResp.json()[0]["id"]) on line 540 of that same file.

In order for the bot to work, I added a conditional that does not run line 540 if there is no length for endpointResp.json(). The bot is running with the latest git codebase, and using Python 3.5.2. Any help is appreciated.

Re-auth fails after Token became invalid (Using Skype-credentials)

After 1 day the reauth after the token became invalid failed.
The credentials should still be present as it wasn't restarted

Running While: 2017-02-21 20:22:00.228576 (Skypetoken valid for 0:00:07.771455)

Error: Error Polling Messages : ("Couldn't retrieve PPFT from login form", <Response [200]>)
Traceback (most recent call last):
  File "SkypeBot.py", line 290, in <function>
    events = sk.getEvents()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 77, in wrapper
    return fn(self, *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 77, in wrapper
    return fn(self, *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/skpy/main.py", line 116, in getEvents
    for json in self.conn.endpoints["self"].getEvents():
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 904, in getEvents
    auth=SkypeConnection.Auth.RegToken).json().get("eventMessages", [])
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 193, in __call__
    self.verifyToken(auth)
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 337, in verifyToken
    self.getRegToken()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 421, in getRegToken
    endpoint.config()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 864, in config
    "version": "908/1.30.0.128"}})
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 193, in __call__
    self.verifyToken(auth)
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 337, in verifyToken
    self.getRegToken()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 421, in getRegToken
    endpoint.config()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 864, in config
    "version": "908/1.30.0.128"}})
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 193, in __call__
    self.verifyToken(auth)
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 337, in verifyToken
    self.getRegToken()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 421, in getRegToken
    endpoint.config()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 864, in config
    "version": "908/1.30.0.128"}})
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 193, in __call__
    self.verifyToken(auth)
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 337, in verifyToken
    self.getRegToken()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 421, in getRegToken
    endpoint.config()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 864, in config
    "version": "908/1.30.0.128"}})
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 193, in __call__
    self.verifyToken(auth)
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 337, in verifyToken
    self.getRegToken()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 421, in getRegToken
    endpoint.config()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 864, in config
    "version": "908/1.30.0.128"}})
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 193, in __call__
    self.verifyToken(auth)
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 337, in verifyToken
    self.getRegToken()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 421, in getRegToken
    endpoint.config()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 864, in config
    "version": "908/1.30.0.128"}})
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 193, in __call__
    self.verifyToken(auth)
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 337, in verifyToken
    self.getRegToken()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 421, in getRegToken
    endpoint.config()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 864, in config
    "version": "908/1.30.0.128"}})
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 193, in __call__
    self.verifyToken(auth)
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 337, in verifyToken
    self.getRegToken()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 415, in getRegToken
    self.verifyToken(self.Auth.SkypeToken)
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 334, in verifyToken
    self.getSkypeToken()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 262, in getSkypeToken
    self.liveLogin(user, pwd)
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 359, in liveLogin
    self.tokens["skype"], self.tokenExpiry["skype"] = SkypeLiveAuthProvider(self).auth(user, pwd)
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 532, in auth
    params = self.getParams()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 543, in getParams
    raise SkypeApiException("Couldn't retrieve PPFT from login form", loginResp)
skpy.core.SkypeApiException: ("Couldn't retrieve PPFT from login form", <Response [200]>)

subsequential calls failed with the same Error although not as many verifyToken-Recursions

Add support for card messages

Cards look like this:

Skype support card message

You can get one from the Skype support bot, thread ID 28:1fa0c494-3cd2-4a7e-9184-91d09a4cef1f.

>>> ch = sk.chats["28:1fa0c494-3cd2-4a7e-9184-91d09a4cef1f"]
>>> ch.sendMsg("help")
>>> # wait for a response...
>>> ch.getMsgs()[0]

Message type is RichText/Media_Card. Sample message content:

<URIObject type="SWIFT.1" url_thumbnail="https://urlp.asm.skype.com/v1/url/content?url=https://neu1-urlp.secure.skypeassets.com/static/card-128x128.png">
  Card - access it on <a href="https://go.skype.com/cards.unsupported">https://go.skype.com/cards.unsupported</a>.
  <Swift b64="..." />
  <Description />
</URIObject>

The b64 attribute encodes a JSON representation of the card:

{
  "attachments": [
    {
      "contentType": "application/vnd.microsoft.card.hero",
      "content": {
        "title": "Thank you for your message!",
        "text": "<p>Please check out the following resources to learn more about Skype.</p>",
        "buttons": [
          {
            "type": "call",
            "title": "Make a test call",
            "value": "echo123"
          },
          {
            "type": "openUrl",
            "title": "Suggest a feature",
            "value": "https://feedback.skype.com/survey/answer/m2i"
          },
          {
            "type": "openUrl",
            "title": "Browse known issues",
            "value": "https://secure.skype.com/login/sso?go=help.litefaq&intsrc=support_bot-help&setlang=en"
          },
          {
            "type": "openUrl",
            "title": "Or... search for cats",
            "value": "https://www.bing.com/images/search?q=cats"
          }
        ]
      }
    }
  ],
  "type": "message/card",
  "recipient": {
    "id": "8:fred.2",
    "name": "Fred Adams"
  },
  "timestamp": "2017-01-01T00:00:00.0000001Z"
}

User-sent cards appear to render successfully in Skype for Web and Skype on Android.

Login fails (response says you need javascript)

Hi @OllieTerrance,
Seems like an amazing effort on this, I wanted to try it out.

I'm currently getting an error page on login (lack of javascript?).
Are you aware of that? Any chance you're still working on this?

Login response content is below:

<html><head><noscript>JavaScript required to sign in<meta http-equiv="Refresh" content="0; URL=https://login.live.com/jsDisabled.srf?mkt=EN-US&lc=1033"/></noscript><title>Continue</title><script type="text/javascript">function OnBack(){}function OnNext(){}function DoSubmit(){var subt=false;if(!subt){subt=true;document.fmHF.submit();}}</script></head><body onload="javascript:DoSubmit();"><form name="fmHF" id="fmHF" action="https://account.live.com/identity/confirm?ru=https://login.live.com/login.srf%3flc%3d1033%26sf%3d1%26id%3d293290%26tw%3d18000%26fs%3d0%26ts%3d-1%26sec%3d%26mspp_shared%3d1%26seclog%3d10%26claims%3d%26wa%3dwsignin1.0%26wp%3dMBI_SSL%26ru%3dhttps://lw.skype.com/login/oauth/proxy%253fclient_id%253d578134%2526site_name%253dlw.skype.com%2526redirect_uri%253dhttps%25253A%25252F%25252Fweb.skype.com%25252F%26contextid%3d04BE3B5D88BB7F54&mkt=EN-US&uiflavor=web&id=293290&uaid=e90d9bd1ae5651536f7a2eec0973805c" method="post" target="_top"><input type="hidden" name="ipt" id="ipt" value="DaPp2!wBwkL9LL!ft0IGD7JIZxRZEX8J9v3eXaoknoP6s8oVyAjKwhkCbDyK*slSLmOA*zU20xRzSK2u8JorfuHEFH3pMoMVakvOGolU0mAdYV6FI!HiOrEPJ8Cebb1ToJO91CiOU*VtEnm!2XvWyPuWKv1pfBa4wl8s5NYTWKaPq0TGo3hp6satWYlUvB1!DEzMHgEc9rKuC7Fl!m03jF8YHTOj3aFwkO*5wq0sy0GJCwEwCLxFD*!Wqwq2w9A1t1XsaiyeV8OWFgOveSt1HdWSXGR2gcvwfyBlF6oPaH8ZVjVSXf7J8EweEYiV6q8RJsMnsI4WgLnFBssU8p3J6wc1lY4TjSDSjtkv*Li2VaAKsTFRfqE2fsvIcdRyqOyhXJPksXfFhK*kedtHTiXw5LoWXhNPcPHp6z0RWSN70N4*dR6eFSwdL7tp4CFqaCF56fA7pV5EcjklGyNmtMpIuBH137UXV1DcRUOeLP9tJWn*"></form></body></html>

SetPresence when using event loops?

Not sure how you would 'set presence' in the event loop example? Bot seems to be offline, even though it is processing events and responding. Any help is much appreciated!

>>> from skpy import SkypeEventLoop
>>> class MySkype(SkypeEventLoop):
...     def onEvent(self, event):
...         print(repr(event))
...
>>> MySkype(tokenFile=".tokens-fred.2", autoAck=True)
MySkype(userId='fred.2')

403 response. The content in the registration token does not match the content in the authentication ticket

[Edited -- don't leak your tokens!]

Hi!
I have written a script that saves the chat history using SkPy.
There is one Skype account that raises error on this line:

sk = Skype(login, pass)

Traceback:
  File "/usr/local/lib/python3.5/dist-packages/skpy/main.py", line 67, in __init__
    self.conn.readToken()
  File "/usr/local/lib/python3.5/dist-packages/skpy/conn.py", line 286, in readToken
    raise SkypeAuthException("No token file specified")
skpy.core.SkypeAuthException: No token file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "skype_2.py", line 10, in <module>
    sk = skpy.Skype(username, password)
  File "/usr/local/lib/python3.5/dist-packages/skpy/main.py", line 69, in __init__
    self.conn.getSkypeToken()
  File "/usr/local/lib/python3.5/dist-packages/skpy/conn.py", line 264, in getSkypeToken
    self.liveLogin(user, pwd)
  File "/usr/local/lib/python3.5/dist-packages/skpy/conn.py", line 363, in liveLogin
    self.getRegToken()
  File "/usr/local/lib/python3.5/dist-packages/skpy/conn.py", line 423, in getRegToken
    endpoint.config()
  File "/usr/local/lib/python3.5/dist-packages/skpy/conn.py", line 866, in config
    "version": "908/1.30.0.128"}})
  File "/usr/local/lib/python3.5/dist-packages/skpy/conn.py", line 217, in __call__
    raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
skpy.core.SkypeApiException: ('403 response from PUT https://db5-client-s.gateway.messenger.live.com/v1/users/ME/endpoints/{b817f8f9-b663-42ca-a874-81bd120c3c0f}/presenceDocs/messagingService', <Response [403]>)

I set SKPY_DEBUG_HTTP=1, and that's what I got:

...
<= [05/05 09:59:58] POST https://client-s.gateway.messenger.live.com/v1/users/ME/endpoints
{'json': {'endpointFeatures': 'Agent'}}
{'BehaviorOverride': 'redirectAs404', 'LockAndKey': '[email protected]; time=1493967598; lockAndKeyResponse=7570fc7a3e61d7efa8ea80d87b909cd9', 'Authentication': 'skypetoken=<snip>'}
=> [05/05 09:59:59] 201
{'Cache-Control': 'no-store, must-revalidate, no-cache',
 'Content-Length': '2',
 'Content-Type': 'application/json; charset=utf-8',
 'ContextId': 'tcid=694389951560002120,server=DB5SCH101121443',
 'Date': 'Fri, 05 May 2017 07:00:04 GMT',
 'Location': 'https://db5-client-s.gateway.messenger.live.com/v1/users/ME/endpoints/%7B411eb5ac-0928-4b7c-8181-b396ba1faa70%7D',
 'Pragma': 'no-cache',
 'Set-RegistrationToken': 'registrationToken=<snip>; '
                          'expires=1494054003; '
                          'endpointId={411eb5ac-0928-4b7c-8181-b396ba1faa70}',
 'X-Content-Type-Options': 'nosniff'}
{}
<= [05/05 09:59:59] PUT https://db5-client-s.gateway.messenger.live.com/v1/users/ME/endpoints/{411eb5ac-0928-4b7c-8181-b396ba1faa70}/presenceDocs/messagingService
{'json': {'id': 'messagingService',
          'privateInfo': {'epname': 'skype'},
          'publicInfo': {'capabilities': '',
                         'nodeInfo': 'xx',
                         'skypeNameVersion': 'skype.com',
                         'type': 1,
                         'version': '908/1.30.0.128'},
          'selfLink': 'uri',
          'type': 'EndpointPresenceDoc'}}
{'RegistrationToken': 'registrationToken=<snip>'}
=> [05/05 09:59:59] 403
{'Cache-Control': 'no-store, must-revalidate, no-cache',
 'Content-Length': '0',
 'ContextId': 'tcid=7144462099043544476,server=DB5SCH101100730',
 'Date': 'Fri, 05 May 2017 07:00:05 GMT',
 'Pragma': 'no-cache',
 'StatusText': 'The content in the registration token does not match the '
               'content in the authentication ticket'}

Thanks in advance!

Add support for message reactions

The latest Android beta introduced emoticon reactions on messages.

Messages now carry an emotions property, for example:

{"from": "https://db5-client-s.gateway.messenger.live.com/v1/users/ME/contacts/8:fred.2",
 "type": "Message",
 "content": "Hello.",
 "conversationLink": "https://db5-client-s.gateway.messenger.live.com/v1/users/ME/conversations/8:joe.4",
 "clientmessageid": "12345678901234567890",
 "composetime": "2017-01-01T00:00:00.000Z",
 "version": "1483228800000",
 "messagetype": "RichText",
 "originalarrivaltime": "2017-01-01T00:00:00.000Z",
 "id": "1483228800000",
 "properties": {"emotions": [{"key": "sarcastic",
                              "users": [{"mri": "8:joe.4",
                                         "time": 1483228800000}]}]}}

These are not currently visible in Skype for Web, though the data is available over the long poll API.

sendfile only works with image=True

I can only send images files with ch.sendfile, using this code:

from skpy import Skype
sk = Skype(login, pass) 
ch = sk.contacts["nixellion"].chat 
ch.sendFile(open(pathToFile, "rb"), fileName, image=True) # file upload

So, if I use image=True, then all images are sent correctly. If I pass a non-image file with image=True, then skype receives it but does not download, just draws a big exclamation mark.

But if I send any file with image=False, then just nothing happens.

Problem talking to a bot

I'm trying to talk to a bot but it raises an exception with a 404 http code:

>>> bot = sk.contacts.bots()[0]
>>> bot
SkypeBotUser(id='57bfbc6f-1556-46fc-b4fa-41ea57b26df6', name='Skyscanner', avatar='https://bot-framework.azureedge.net/bot-icons-v1/skyscanner_FvFDzr8uU6X5BNhm38qR3yTwCGsj1S191u7vbEF96nnaP.png', developer='Skysc
anner', trusted=True, locales=[], rating=0.0, description="The world's travel search engine", extra='<a href="https://www.skyscanner.net/termsofservice.aspx">Terms of Service</a><br/><a href="https://www.skyscan
ner.net/privacypolicy.aspx">Privacy Statement</a>', siteUrl='https://www.skyscanner.net', termsUrl='https://www.skyscanner.net/termsofservice.aspx', privacyUrl='https://www.skyscanner.net/privacypolicy.aspx')
>>> bot_chat = bot.chat
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    bot_chat = bot.chat
  File "/home/adrian/.virtualenvs/test/lib/python3.6/site-packages/skpy/util.py", line 227, in wrapper
    cache[key] = fn(*args, **kwargs)
  File "/home/adrian/.virtualenvs/test/lib/python3.6/site-packages/skpy/user.py", line 309, in chat
    return self.skype.chats["28:" + self.id]
  File "/home/adrian/.virtualenvs/test/lib/python3.6/site-packages/skpy/chat.py", line 391, in __getitem__
    return self.chat(key)
  File "/home/adrian/.virtualenvs/test/lib/python3.6/site-packages/skpy/chat.py", line 427, in chat
    auth=SkypeConnection.Auth.RegToken, params={"view": "msnp24Equivalent"}).json()
  File "/home/adrian/.virtualenvs/test/lib/python3.6/site-packages/skpy/conn.py", line 215, in __call__
    raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
skpy.core.SkypeApiException: ('404 response from GET https://db5-client-s.gateway.messenger.live.com/v1/users/ME/conversations/28:57bfbc6f-1556-46fc-b4fa-41ea57b26df6', <Response [404]>)

I have also problems trying to add a private bot:

>>> sk.contacts.bot("xxxxx4269-ac27-8c584ae6a29d")
SkypeContact(id='xxxxx-4269-ac27-8c584ae6a29d', name='xxxx', location=Location(), avatar='https://bot-framework.azureedge.net/bot-icons-v1/bot_DBMFdnxxxxxE3E193358Y4AYf1vEC6R2VP4Kr.png', aut
horised=True, blocked=False, favourite=True)

It returns a SkypeContact instead of a SkypeBotUser object.

With the id of the skyscanner bot it works well (creating the object, chat doesn't work neither):

>>> sk.contacts.bot("57bfbc6f-1556-46fc-b4fa-41ea57b26df6")
SkypeBotUser(id='57bfbc6f-1556-46fc-b4fa-41ea57b26df6', name='Skyscanner', avatar='https://bot-framework.azureedge.net/bot-icons-v1/skyscanner_FvFDzr8uU6X5BNhm38qR3yTwCGsj1S191u7vbEF96nnaP.png', developer='Skysc
anner', trusted=True, locales=[], rating=0.0, description="The world's travel search engine", extra='<a href="https://www.skyscanner.net/termsofservice.aspx">Terms of Service</a><br/><a href="https://www.skyscan
ner.net/privacypolicy.aspx">Privacy Statement</a>', siteUrl='https://www.skyscanner.net', termsUrl='https://www.skyscanner.net/termsofservice.aspx', privacyUrl='https://www.skyscanner.net/privacypolicy.aspx')

Sync state links are shared between unrelated objects

Calling getMsgs() on conversation A, then getMsgs() on conversation B, we always get A's messages due to following the sync state URLs retrieved from the first call.

getMsgs.state.clear() resets this for the next call, but state should be stored per-conversation.

Change to registration token auth

The behaviour of <msgsHost>/users/ME/endpoints has changed on Skype for Web:

  • JSON request contains {"endpointFeatures": "Agent"}
    • can't see any visible effects of providing this though
  • response codes are now 200 for "ok", 404 for redirect
    • previously 201 for created, 301 for redirect
    • ok status regardless of whether a new endpoint was created, or already exists?
  • endpoint identifier can now be present in the Set-RegistrationToken header
    • registrationToken=..., expires=..., endpointId={...}
  • JSON response contains array of all endpoints and their subscriptions
    • doesn't appear to be a way to tell which endpoint we want, currently just taking the first one

Also interesting to note:

  • endpoints with "channelType" set to "TcpSocket" as opposed to "HttpLongPoll"
    (presumably non-web clients -- would be nice to implement)

Can't send msg

Hi all!

I have a problem with sending message by this module. I write code like at example, but it does not work. I created a new account on skype and added to my contacts list - live:8584067c9701be5c, because for old contacts in my contact list i can't send msg too. And if i will not put tokenFile param into Skype init i can't login by my acc, but it is another story':). So look:

sk = Skype(login, get_pass(), tokenFile=".tokens-fred.2") # connect to Skype
ch = sk.contacts['live:8584067c9701be5c'].chat
ch.sendMsg('hello')

And i get the error:

Traceback (most recent call last):
File "%user_path%/bot/bot_main.py", line 88, in
ch.sendMsg('hello')
File "%user_path%\lib\site-packages\skpy\chat.py", line 140, in sendMsg
"Has-Mentions": mentions, "skypeemoteoffset": meOffset})
File "%user_path%lib\site-packages\skpy\chat.py", line 81, in sendRaw
auth=SkypeConnection.Auth.RegToken, json=msg).json().get("OriginalArrivalTime")
File "%user_path%\lib\site-packages\skpy\conn.py", line 215, in call
raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
SkypeApiException: ('400 response from POST https://client-s.gateway.messenger.live.com/v1/users/ME/conversations/8:live:8584067c9701be5c/messages', <Response [400]>)
Uncaught exception

Thanks for all and best regards

event.msg.chat throwing exception for non-group chats

Hey there,

I'm trying to write a small bot for some user interaction via skype.

  def onEvent(self, event):

    if isinstance(event, SkypeNewMessageEvent) and not event.msg.userId == self.userId:
      text = event.msg.plain().strip()

      if text.startswith("!") and len(text) > 1:
        command = text[1:].split(" ")[0].lower()

        if command == "test":
          print(repr(event))
          print(repr(event.msg))
          print(repr(event.msg.chat))

When I send a message to the SkPy account in a group chat I can see the following:

SkypeNewMessageEvent(id=1064, type='NewMessage', time=datetime.datetime(2016, 11, 8, 13, 30, 2), msgId=<msgId>)
SkypeTextMsg(id='<msgId>', type='RichText', time=datetime.datetime(2016, 11, 8, 13, 30, 2, 855000), clientId='<clientId>', userId='live:<myUser>', chatId='19:<myGroupChat>@p2p.thread.skype', content='!test')
SkypeGroupChat(id='19:<myGroupChat>@p2p.thread.skype', topic='<topic>', creatorId='<creatorId>', userIds=['live:<myUser>', '<skpyUser>', 'and', 'some', 'others'], adminIds=['<others>'], open=False, history=False, picture='https://api.asm.skype.com/v1/objects/<whatever>/views/avatar_fullsize')

However, when I send a message directly it can't access the chat attribute on event.msg:

SkypeNewMessageEvent(id=1067, type='NewMessage', time=datetime.datetime(2016, 11, 8, 13, 30, 20), msgId=<msgId>)
SkypeTextMsg(id='<msgId>', type='Text', time=datetime.datetime(2016, 11, 8, 13, 30, 20, 433000), clientId='<clientId>', userId='live:<myUser>', content='!test')
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/skpy/chat.py", line 370, in __getitem__
    return super(SkypeChats, self).__getitem__(key)
  File "/usr/lib/python3.5/site-packages/skpy/core.py", line 138, in __getitem__
    return self.cache[key]
KeyError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./run.py", line 78, in <module>
    main()
  File "./run.py", line 73, in main
    sk.loop()
  File "./run.py", line 49, in loop
    self.cycle()
  File "/usr/lib/python3.5/site-packages/skpy/main.py", line 205, in cycle
    self.onEvent(event)
  File "./run.py", line 38, in onEvent
    print(repr(event.msg.chat))
  File "/usr/lib/python3.5/site-packages/skpy/util.py", line 148, in chatObj
    return self.skype.chats[getattr(self, field)]
  File "/usr/lib/python3.5/site-packages/skpy/chat.py", line 372, in __getitem__
    return self.chat(key)
  File "/usr/lib/python3.5/site-packages/skpy/chat.py", line 408, in chat
    auth=SkypeConnection.Auth.RegToken, params={"view": "msnp24Equivalent"}).json()
  File "/usr/lib/python3.5/site-packages/skpy/conn.py", line 214, in __call__
    raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
skpy.core.SkypeApiException: ('400 response from GET https://db5-client-s.gateway.messenger.live.com/v1/users/ME/conversations/None', <Response [400]>)

Am I supposed to check whether the message is coming from a group chat first?
If so, how would I do that? Checking whether the SkypeTextMsg has the chatId attribute?

call forwarding

Hey there, is it possible to setup call forwarding (a.k.a. call transfers) with this API?

404 error while trying to login via Live (Microsoft) account.

HI,

When i try to login using Skype account, its working fine

But when i try to login using Live (Microsoft) account, its throwing 404 error

('404 response from PUT https://client-s.gateway.messenger.live.com/v1/users/ME/endpoints/5434e4d6-34f7-9d2c-783d-8dbc04cfe714/presenceDocs/messagingService', <Response [404]>)

Account type

Conversation details

Steps to reproduce

Just trying to login

from skpy import Skype

from getpass import getpass

Skype("[email protected]", getpass())

Result or traceback

Password:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/skpy/main.py", line 67, in init
self.conn.readToken()
File "/usr/local/lib/python3.6/site-packages/skpy/conn.py", line 284, in readToken
raise SkypeAuthException("No token file specified")
skpy.core.SkypeAuthException: No token file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "test.py", line 5, in
Skype("[email protected]", getpass())
File "/usr/local/lib/python3.6/site-packages/skpy/main.py", line 69, in init
self.conn.getSkypeToken()
File "/usr/local/lib/python3.6/site-packages/skpy/conn.py", line 262, in getSkypeToken
self.liveLogin(user, pwd)
File "/usr/local/lib/python3.6/site-packages/skpy/conn.py", line 361, in liveLogin
self.getRegToken()
File "/usr/local/lib/python3.6/site-packages/skpy/conn.py", line 421, in getRegToken
endpoint.config()
File "/usr/local/lib/python3.6/site-packages/skpy/conn.py", line 864, in config
"version": "908/1.30.0.128"}})
File "/usr/local/lib/python3.6/site-packages/skpy/conn.py", line 215, in call
raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
skpy.core.SkypeApiException: ('404 response from PUT https://client-s.gateway.messenger.live.com/v1/users/ME/endpoints/5434e4d6-34f7-9d2c-783d-8dbc04cfe714/presenceDocs/messagingService', <Response [404]>)

Couldn't retrieve Skype token from login response

Hi! I am novice in python, but I really liked you API, I used it successfuly in September-October, but now I am facing some issues when trying to run it, here's traceback:
Traceback (most recent call last):
File "zabbix-parsing.py", line 23, in
sk = Skype("my_login", "my_password") # connect to Skype
File "/usr/local/lib/python2.7/dist-packages/skpy/main.py", line 70, in init
self.conn.getSkypeToken()
File "/usr/local/lib/python2.7/dist-packages/skpy/conn.py", line 259, in getSkypeToken
self.login(user, pwd)
File "/usr/local/lib/python2.7/dist-packages/skpy/conn.py", line 392, in login
raise SkypeApiException("Couldn't retrieve Skype token from login response", loginResp)
skpy.core.SkypeApiException: ("Couldn't retrieve Skype token from login response", <Response [200]>)

Thanks in advance

Switch to v2 contacts API

Would allow access to contact list groups and blocked contacts. Quite a lot of refactoring to do though.

  • Contact list: /contacts/v2/users/{you}
    {"contacts": [...], "groups": [...], "blocklist": [...]}
    • Contacts
    • Groups
    • Blocked
  • Contact requests: /contacts/v2/users/{you}/invites
    {"invite_list": [...]}
  • Accept/decline requests: /contacts/v2/users/{you}/invites/8:{them}/{accept,decline}
  • Update protocol docs too!

Can't login

Hi ! Sorry for my bad english

Traceback (most recent call last):
  File "H:\Desktop\Mes_codes\Python\Skpy script\skype_pic2html.py", line 29, in <module>
    sk = MySkype("XXX", "XXX", autoAck=True)
  File "C:\Python27\lib\site-packages\skpy\main.py", line 189, in __init__
    super(SkypeEventLoop, self).__init__(user, pwd, msEmail, msPwd, tokenFile)
  File "C:\Python27\lib\site-packages\skpy\main.py", line 65, in __init__
    self.conn.getSkypeToken()
  File "C:\Python27\lib\site-packages\skpy\conn.py", line 261, in getSkypeToken
    self.liveLogin(user, pwd)
  File "C:\Python27\lib\site-packages\skpy\conn.py", line 378, in liveLogin
    data={"t": tField.get("value"), "client_id": "578134", "oauthPartner": "999",
AttributeError: 'NoneType' object has no attribute 'get'

When :
sk = MySkype("XXX", "XXX", autoAck=True)

it's worked before, any idea please ? thanks !

EDIT : Btw :

>pip install skpy --upgrade
Requirement already up-to-date: skpy in c:\python27\lib\site-packages

Need a little help i'm confused.

I'm trying to write something that waits for messages and then responds, But i am having problems doing that could anyone here show me how to write that? Please?

Use SkyPy to check if user exists

Hello,

I'm wondering there's a way to check if given username exists without pass a password.
I'd like to use SkPy to verify a list of users and delete all "non-skype-user" from it.

Could you give me some hint?

Cheers!

Retrieving a contact's presence ?

I managed to retrieve a skpy.user.SkypeContact, however I have looked into this object's attributes in the docs and I can't find a way to get the contact's presence (online, ...).

Using the event system, I sometimes receive SkypeEndpointsEvents that indicate the presence of an active contact, but is there a way to get it for any contact even if they are inactive ?

When initialing the instance, I got this error.

Traceback (most recent call last):
File "C:\Users\hao\Desktop\lil_tool_py\skype\test.py", line 4, in
sk = Skype(username, password) # connect to Skype
File "C:\Python27\lib\site-packages\skpy\main.py", line 69, in init
self.conn.getSkypeToken()
File "C:\Python27\lib\site-packages\skpy\conn.py", line 262, in getSkypeToken
self.liveLogin(user, pwd)
File "C:\Python27\lib\site-packages\skpy\conn.py", line 361, in liveLogin
self.getRegToken()
File "C:\Python27\lib\site-packages\skpy\conn.py", line 423, in getRegToken
self.syncEndpoints()
File "C:\Python27\lib\site-packages\skpy\conn.py", line 433, in syncEndpoints
params={"view": "expanded"}, auth=self.Auth.RegToken).json().get("endpointPresenceDocs", []):
File "C:\Python27\lib\site-packages\skpy\conn.py", line 215, in call
raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
SkypeApiException: ('404 response from GET https://client-s.gateway.messenger.live.com/v1/users/ME/presenceDocs/messagingService', <Response [404]>)

TypeError upon inputting password

I consistently get this error when attempting to sign into Skype:

TypeError: request() got an unexpected keyword argument 'json'

I'm just using the code from the basic usage page.

from skpy import Skype
from getpass import getpass

Skype("[username]", getpass())

I upgraded the Requests library to 2.11.1 in both Python 2.7 and Python 3, but I still get this error. I'm using Ubuntu 14.04.

Here's the full traceback in Python 2.7:

Traceback (most recent call last):
  File "[path]/run.py", line 4, in <module>
    sk = Skype("[username]", getpass())
  File "build/bdist.linux-i686/egg/skpy/main.py", line 70, in __init__
  File "build/bdist.linux-i686/egg/skpy/conn.py", line 262, in getSkypeToken
  File "build/bdist.linux-i686/egg/skpy/conn.py", line 404, in login
  File "build/bdist.linux-i686/egg/skpy/conn.py", line 521, in getRegToken
  File "build/bdist.linux-i686/egg/skpy/conn.py", line 205, in __call__
TypeError: request() got an unexpected keyword argument 'json'

And in Python 3:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/skpy/main.py", line 68, in __init__
    self.conn.readToken()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 294, in readToken
    raise SkypeAuthException("No token file specified")
skpy.conn.SkypeAuthException: No token file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "[path]/run.py", line 4, in <module>
    sk = Skype("[username]", getpass())
  File "/usr/local/lib/python3.4/dist-packages/skpy/main.py", line 70, in __init__
    self.conn.getSkypeToken()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 259, in getSkypeToken
    self.login(user, pwd)
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 401, in login
    self.getRegToken()
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 518, in getRegToken
    headers=headers, json={"endpointFeatures": "Agent"})
  File "/usr/local/lib/python3.4/dist-packages/skpy/conn.py", line 202, in __call__
    resp = self.sess.request(method, url, headers=headers, **kwargs)
TypeError: request() got an unexpected keyword argument 'json'

live account not working

ok so i've been trying to make a basic skype bot for a while with a code similar to the ping/pong snippet from the docs.
i can log into the live accounts i made on skype in my browser, but it ends up with skpy.core.SkypeAuthException: (u"That Microsoft account doesn't exist. Enter a different account or get a new one.", <Response [200]>)
here is the code if you need it https://paste.kde.org/po0ay3f7u

Drop Skype auth, make Microsoft auth default

Looks like all logins, Microsoft account or not, now go via login.live.com. To my amazement, Skype-only accounts can use Skype(msEmail=<username>, msPwd=<password>) out of the box.

Card messages not rendering

Hi, I got this error when I try to run:
raise SSLError(e, request=request)
requests.exceptions.SSLError: hostname 'login.live.com' doesn't match u'gateway.
login.live.com'

Token issue

Hey there,

I just noticed this exception in my log, I don't know how to reproduce this though, hopefully it's enough info for you to see the issue already:

Traceback (most recent call last):
  File "./run.py", line 119, in <module>
    main()
  File "./run.py", line 114, in main
    sk.loop()
  File "./run.py", line 97, in loop
    self.cycle()
  File "/usr/lib/python3.5/site-packages/skpy/main.py", line 201, in cycle
    events = self.getEvents()
  File "/usr/lib/python3.5/site-packages/skpy/conn.py", line 76, in wrapper
    return fn(self, *args, **kwargs)
  File "/usr/lib/python3.5/site-packages/skpy/conn.py", line 76, in wrapper
    return fn(self, *args, **kwargs)
  File "/usr/lib/python3.5/site-packages/skpy/main.py", line 112, in getEvents
    for json in self.conn.endpoints["self"].getEvents():
  File "/usr/lib/python3.5/site-packages/skpy/conn.py", line 572, in getEvents
    auth=SkypeConnection.Auth.RegToken).json().get("eventMessages", [])
  File "/usr/lib/python3.5/site-packages/skpy/conn.py", line 192, in __call__
    self.verifyToken(auth)
  File "/usr/lib/python3.5/site-packages/skpy/conn.py", line 336, in verifyToken
    self.getRegToken()
  File "/usr/lib/python3.5/site-packages/skpy/conn.py", line 444, in getRegToken
    self.verifyToken(self.Auth.SkypeToken)
  File "/usr/lib/python3.5/site-packages/skpy/conn.py", line 333, in verifyToken
    self.getSkypeToken()
  File "/usr/lib/python3.5/site-packages/skpy/conn.py", line 261, in getSkypeToken
    self.liveLogin(user, pwd)
  File "/usr/lib/python3.5/site-packages/skpy/conn.py", line 357, in liveLogin
    ppft = re.search(r"""<input.*?name="PPFT".*?value="(.*?)\"""", loginResp.text).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.