我的java项目需要帮助.我正在尝试在特定操作发生时在Skype对话中发送消息.
为此,我使用taskan的java-skype API v1.4.
这是我的代码:
try {
for (Group group : Skype.getContactList().getAllGroups()) {
if ((group.getDisplayName()).equals("Nameofthegroup")) { //Whatever the group name is
String id = group.getId();
Skype.chat(id).send(ep.getDisplayName() + " joins !");
ep.sendMessage("Die ID: "+ id);
}
}
} catch (Exception e3) {
e3.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
try {
String id = Skype.getContactList().getGroup("Groupname").getId();
Skype.chat(id).send(p + "joins!");
} catch (SkypeException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
我的问题是Skype注册外部程序尝试做某事,但在我允许访问Java之后,没有其他事情发生.没有消息被发送.
我对 Skype API 不太了解,但您可以查看示例以获取帮助。如果您想在有人向您发送聊天消息时发送聊天消息,您可以使用自动应答示例:
package com.skype.sample;
import com.skype.ChatMessage;
import com.skype.ChatMessageAdapter;
import com.skype.Skype;
import com.skype.SkypeException;
public class AutoAnswering {
public static void main(String[] args) throws Exception {
Skype.setDaemon(false); // to prevent exiting from this program
Skype.addChatMessageListener(new ChatMessageAdapter() {
public void chatMessageReceived(ChatMessage received) throws SkypeException {
if (received.getType().equals(ChatMessage.Type.SAID)) {
received.getSender().send("I'm working. Please, wait a moment.");
}
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
您的代码中有一个未定义的变量ep,因此我无法给您更好的答案。我本来会发表评论询问此事,但 Stack Overflow 不允许新人发表评论。
| 归档时间: |
|
| 查看次数: |
12456 次 |
| 最近记录: |