taksan / skype-java-api

Skype API for Java, based on Skype4Java library
128 stars 60 forks source link

Skype for Java throws exception while using in Group Chat #45

Open sandeeprock12 opened 10 years ago

sandeeprock12 commented 10 years ago

I have been Skype for Java API successfully in singular chats. But, I am getting an exception while using it in Group Chat. Below is the exception:

com.skype.CommandFailedException: Invalid/uknown chat name given at com.skype.Utils.checkError(Utils.java:77) at com.skype.Chat.send(Chat.java:275) at skypePackage.MyListener.myListener(MyListener.java:85) at skypePackage.MyListener.chatMessageReceived(MyListener.java:220) at com.skype.ChatMessageConnectorListener.fireMessageReceived(ChatMessageConnectorListener.java:58) at com.skype.ChatMessageConnectorListener.messageReceived(ChatMessageConnectorListener.java:38) at com.skype.connector.Connector.fireMessageEvent(Connector.java:1119) at com.skype.connector.Connector.access$500(Connector.java:37) at com.skype.connector.Connector$13.run(Connector.java:1098) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

Please help!

bglasber commented 10 years ago

I am experiencing the exact same behaviour, but only on recent group chats. If I use the API against an older chat (I tested with several years and several months), it works as expected.

I can provide more details as need be.

Thanks!

sandeeprock12 commented 10 years ago

Thanks for your response, Brad! I too sort of figured out this issue. But, I am stuck with another one. Please let me know if you can help. Below are the details:

I am trying to develop a Skype Bot which can process some messages and respond to them. I am using the Skype for Java API for the same. I am using a listener implementing the "ChatMessageListener" interface. I randomly (almost 70% of the times) get duplicate receipts of the messages.

bglasber commented 10 years ago

I'm not entirely sure about the ChatMessageListener, but I have experienced a similar issue when using a chat message adapter.

It appears to be caused by adjusting focus to the skype window after a message is received, since for some reason this seems to call the listener twice.

A similar issue is referenced here: https://github.com/taksan/skype-java-api/issues/30

As a workaround you could check the id on the ChatMesasge object and compare it to the one you just received to see if it is a duplicate or not, but this should probably be fixed in the API.

If I get a chance I might take a look at the previous dbus issue and this one and see what I can do.

sandeeprock12 commented 10 years ago

Thanks Brad! I'll try to look into the direction that you had mentioned to see if I can resolve the duplication issue.

I have one more question for you for the time being, which version of the Skype for Java do you use? 1.4 or 1.5?

bglasber commented 10 years ago

I'm using 1.4

sandeeprock12 commented 10 years ago

Thanks. I am using the same version too. Also, I was able to resolve the issue with duplicate messages.

However, I am facing a another issue. That is, when I am using multiple chats to query the Skype Bot, only the chat I am currently focusing on the Skype bot account is responsive. Other chats that the Skype bot account doesn't have focus on is not responsive. Only when I move the focus to other chats, the messages for those particular chats are getting delivered.

Please let me know if you have any idea on this... :)

bglasber commented 10 years ago

I've experienced similar issues, but I've never had that issue exactly. It seems that when no chats are focused, all the messages are received. I have a bot that it is 3 fairly active chats and it doesn't seem to miss much. Of course, if I were to focus a window, suddenly duplicates start rolling in.

I've been running the bot on Linux and keeping the skype chat windows on separate "workspace," which seems to resolve the focus issue. I'm not sure about how to achieve this on other platforms, but perhaps minimizing the chat windows for the groups the bot is in will work.

sandeeprock12 commented 10 years ago

Hi Brad,

I am also seeing the exception while using in group chats in new group chats. Do you know how old a chat has to be for the Skype bot to work properly?

Also, once added to a new group and you start getting exceptions, is there a way to make it work on those chats again?

Also, is it bcoz for the new chats there is no name initially?

Please help me details that you have...

bglasber commented 10 years ago

I'm not sure how new it has to be, I haven't run extensive tests on it. I'd tried setting the title, topic, etc, on the chat and nothing seems to work. As far as I know, there isn't a way to make new chats work. The fact that old chats work and new chats don't seems to imply a change in Skype itself. I think the problem is that the API is looking up the chat based on a property that no longer exists.

If that is the case, then in order to fix this, you would need to figure out how Skype chats are identified now, and then adjust the API code to find this new property (or fall back to the old method if it isn't present.)

I'm not too sure of any details, largely because I don't know the API codebase or the skype interface very well. If no one picks up the issue in the interim and I have a lot of free time, I'll look into it.

sandeeprock12 commented 10 years ago

Hi,

I found out the root cause of this issue. The issue is due to change in version of Skype desktop client for Windows and MAC. The issue can be attributed to the change in the format of the Group Chat ID.

You can get the change in formats of the Group Chat ID by printing the values of "getChat.getID()". Below are some sample Chat IDs:

Old Skype Version - #--Username--/$--Username--;19a7be37a4cf94de New Skype Version - 19:9d4dd3d52f134c978b5c3f4515c15e6f@thread.skype

I have tested the creation of group chats in previous versions of Skype client on MAC and Windows and it works fine then. Skype bot fails in group chats only created using the latest version of Skype.

The Skype for Java API code base needs to be updated to account for the new format of Chat ID.

taksan commented 10 years ago

As far as I know, the latest skype versions aren't even supposed to support the desktop API. So, it isn't surprising that interaction with new versions are becoming problematic. I admit that I didn't look into the issue, I'd have to check whether it is even possible to interact with groups created by the new API.

sandeeprock12 commented 10 years ago

Hi @taksan,

Thanks for your response! The issue with a group chat is only when it is created by newer version of Skype. If a chat is created in an older version of Skype and then the creator of that group chat updated to a newer version, it doesn't matter the Skype bot still works. It doesn't work only if the group chat is created in a newer version of Skype.

Below are the versions that I have tested in Windows and MAC:

Windows -- Newer - 6.16.60.105, Older - 5.10.0.116 MAC -- Newer - 6.18, Older - 6.0.0.2946

sandeeprock12 commented 10 years ago

Hi @taksan,

The issue is of importance as the version of Skype the Skype Bot is running does not matter and only the Skype version creating the group chat matters.

taksan commented 9 years ago

Yeah, I got it. I'd have to test the new version against the API and see whether it is possible to extract the information required to deal with group chats created by newer versions. If so, then I'd have to implement strategies to handle both kinds of group chats.

I'm bit of out time, but I'll see what I can do.

Thanks for you throughout analysis.

sandeeprock12 commented 9 years ago

Thanks for your response, Gabriel! I appreciate your help.

I was looking at the Skype for Java API code and found the area where we are receiving the exception while using the new chat IDs. The place the new ID is coming into play is in the 'executeWithId()' and 'execute()' methods within the 'Connector' class in the 'com.skype.connector' package.

Also, I can dedicate some time to update the Skype for Java API. Please provide your guidance and I can work something out... :)

Hope this info helps.

sandeeprock12 commented 9 years ago

Hi @taksan,

Any luck? Also, could you give me you email ID so that I can contact you easily. My email ID is sandeeprock12@gmail.com

sandeeprock12 commented 9 years ago

Hi @taksan,

The issue with the newer versions of Skype is that we are able to receive all the messages from the group chat. But, the issue is when we are trying to send response message to the group chat. So getting the information from the group chat is not the issue. Only the sending part is the issue...

com.skype.CommandFailedException: Invalid/uknown chat name given at com.skype.Utils.checkError(Utils.java:77) at com.skype.Chat.send(Chat.java:275)

sandeeprock12 commented 9 years ago

Hi @taksan,

Did you get any time to look at group chat exceptions created from the newer versions of Skype. Currently, Skype doesn't allow users to log in to older versions versions. Only, the newest version can be used.

evluhin commented 9 years ago

Any updates on this issue?

EionRobb commented 9 years ago

The Skype Desktop API doesn't support the new "@thread.skype" chat ids. This isn't a problem with just the Java API either and there is no way to resolve.

evluhin commented 9 years ago

it's possible to do a workaround I think. I found possible solution here http://habrahabr.ru/post/235007/ (russian text) The idea is to listen message db, Skype uses sqlite3. But it'll work only in read only mode.

X-com commented 9 years ago

I have desperately been trying to find a solution for the group chats. When using Skype.getAllChats(); the group chats simply wont show up at all. Anyone know of any workaround? If not even that, any way to downgrade skype to the earliest possible version where group chats can be searched using the api?

Using jdk 1.8.31 skype 6.20 Windows 7 operating system.

Cuniq commented 9 years ago

check my answer here

X-com commented 9 years ago

I did try both methods and neither picked up group chats. There are some older group chats in my contacts list, oddly those it can find but any new group chats created simply are not showing up at all.

What version of Skype did you test this on? could it also be related to some form of setting?

EionRobb commented 9 years ago

You're not going to be able to use the old skype Api with new chat threads as they're not accessible from the desktop Api. You'd have to implement msnp24 or use the new skype for web which is in closed beta On 9/03/2015 10:15 pm, "X-com" notifications@github.com wrote:

I did try both methods and neither picked up group chats. There are some older group chats in my contacts list, oddly those it can find but any new group chats created simply are not showing up at all.

What version of Skype did you test this on? could it also be related to some form of setting?

Reply to this email directly or view it on GitHub https://github.com/taksan/skype-java-api/issues/45#issuecomment-77820844 .