使用 Skype4py 将联系人添加到 Skype



>我看到了这个线程:

Skype4Py - 如何成功添加联系人?

在底部,这段代码:

sky = Skype4Py.Skype()
sky.Attach()
user = sky.SearchForUsers('someUser')
print user

并引用:

例如,应该给你一个句柄来添加我。例如,在您收到的对象中,将有一个选项可以添加我。

所以我的问题是"该对象中到底有什么功能,因为我在文档中没有发现类似"addContact()"的内容???"

这是文档的链接:

http://skype4py.sourceforge.net/doc/html/

或选项 2:

我应该通过客户端对象按下按钮(发送事件)吗?

sky = Skype4Py.Skype()
sky.Attach()
client = Skype4Py.client.Client(sky)
client.OpenAddContactDialog("someUser")

简单的 20 行片段会向我澄清这一点,因为除了文档链接之外,谷歌上几乎还有 Skype4py 的任何示例。

@Torxed在他的

回答中指出了方法:

http://skype4py.sourceforge.net/doc/html/Skype4Py.user.User-class.html#SetBuddyStatusPendingAuthorization

以下是您的使用方式:

import Skype4Py
sky = Skype4Py.Skype()
sky.Attach()
requestMessage = "Please accept my request!"
searchResults = sky.SearchForUsers('echo123')
firstResult = searchResults[0]
firstResult.SetBuddyStatusPendingAuthorization(requestMessage)

请注意,因为这只会添加搜索返回的第一个结果。如果你的用户名准确无误,应该没问题。

最新更新