Skype4Py / Skype4Py

Platform independent Python wrapper for the Skype Desktop API
BSD 3-Clause "New" or "Revised" License
447 stars 105 forks source link

AddMembers() not getting expected reply #16

Open prajna-pranab opened 11 years ago

prajna-pranab commented 11 years ago

When calling chat.AddMembers(user) the following exception is raised:

SkypeError: [Errno 0] Unexpected reply from Skype, got [ALTER CHAT ADDMEMBERS], expected [ALTER CHAT #messageId ADDMEMBERS (...)]

I have replaced the actual message Id with #messageId in the exception text above.

It appears that the skype api doesn't return the message id in the response message or if it does it returns it after the ALTER CHAT ADDMEMBERS text.

I'm using skype4py inside a web2py application on ubuntu 12.04. I'm using the X11 transport because dBus reports an error the second time the app is run. I'll post that as a separate issue.

Thanks for the pointer to here Mikko.

miohtama commented 11 years ago

Do you know what is causing this issue yet?

We can enable Skype API log traces so you can see the communication between Skype and Skype4Py?

prajna-pranab commented 11 years ago

I believe it is just an error in the expected reply, Mikko. Generally the API strips off the word at the front of the command (SET or GET) and returns the rest of the command (unless I read that wrong in the api docs). In the case of AddMembers() it only returns ALTER CHAT ADDMEMBERS but the skype4py code uses startsWith(expected) and raises the exception. Thats how it seems to me. I thought that changing the 'expected' text might fix it but addmembers is only one of a number of ALTER commands and the others may send the expected replies ok.

The api is returning the correct string, according to the docs. It seems that skype4py is expecting it to return the chat ID embedded in the response string, but the api doesn't.

miohtama commented 11 years ago

Good!

So, to try a fix on this:

Hopefully this gets us started towards the fix :)

prajna-pranab commented 11 years ago

Hi Mikko, I have identified the problem and found a solution and am about to test it. It seems that for most of the ALTER commands the API responds by echoing the command, including the call_id, voicemail_id etc. For some strange reason this convention is departed from with the ALTER CHAT commands, where the command is echoed without the chat_id. Thus it is simple to fix by just removing the self.Name argument from the expected reply string in chat.py's _Alter method.

prajna-pranab commented 11 years ago

The modification needed is in chat.py at line 20 in _Alter()

change from: return self._Owner._Alter('CHAT', self.Name, AlterName, Args, 'ALTER CHAT %s %s' % (self.Name, AlterName)) change to: return self._Owner._Alter('CHAT', self.Name, AlterName, Args, 'ALTER CHAT %s' % (AlterName))

This corrects the exception I was receiving when adding members to a chat group. The rationale is explained above.

I would be very pleased if someone could incorporate this fix, since I am unfamiliar with git and it would require some time for me to work out how to commit my changes back to my fork and have them merged back.

regards, Prajna

miohtama commented 11 years ago

Hi @prajna-pranab

All patches go through the following process:

  1. Hit Fork button on Github -> creates your private clone
  2. Follow Github instructions to make local git clone using commandline
  3. Create your change in your local git clone
  4. Run unit tests
  5. Update CHANGES.txt
  6. git add, git commit, git push to local fork from the command line
  7. Go to your local fork on Github web interface, press Make Pull Request button
miohtama commented 11 years ago

If you need any clarifications please ask me