banner
Miagz

Miagz

一个很新的网站

The Birth of Skype Ai

The Birth of "Skype Ai"#

1. Introduction#

Microsoft's new Bing cannot be used in mainland China for reasons that cannot be described. At first, there was a way to bypass the regional restrictions by modifying the X-Forwarder-For in the header. However, it was soon fixed. So here comes this article.

2. Getting Started#

Microsoft introduced NewBing into Skype, allowing users to use NewBing features in chats. The model used by New Bing is GPT4.0, which means we can use GPT4.0 for free in Skype. Unfortunately, private chats with NewBing in Skype still require the use of "magic" to work.

CleanShot 2023-08-04 at 22.15.02@2x

Once the magic is cast,

CleanShot 2023-08-05 at 01.09.41@2x

However, in group chats, there is no need to use magic to mention NewBing. It seems that we have found a breakthrough.

CleanShot 2023-08-05 at 01.24.34@2x

But in mainland China, Skype is not as widely used as WeChat or QQ. If we need to use NewBing in Skype every time, do we have to open Skype, open the group chat, and mention NewBing every time? So I decided to use a Python script to call NewBing in Skype. At first, I used Python web scraping to do it. But after some in-depth understanding, I found a library called skpy in Python. I have put the entire code on GitHub, and I will only talk about some of the more difficult issues below. If you don't want to read the rest, you can go to my GitHub.

Python Access to Skype Group Chats#

Skpy uses chats to access group conversations, and chats require the group ID as a parameter. The following is the code to get the group ID:

loggedInUser = Skype("[email protected]", "password")
getinfo = SkypeChats(loggedInUser)
print(getinfo.recent())

The Topic parameter in the output JSON is the name of the created group chat, and the group ID can be located based on the group chat name. The format of the group ID is usually: 19:[email protected]

CleanShot 2023-08-05 at 02.20.46@2x

Summoning BingChat#

After using skpy to access Skype in Python, it is possible to successfully send messages to group chats in Python. However, simply mentioning NewBing in Python does not successfully wake up NewBing. By using BurpSuite to capture packets, it was discovered that a string like the following appears every time NewBing is mentioned:

<at id=\"28:cf0e6215-34fe-409b-9e4b-135d7f3aa13b\">Bing</at>

Trying to put this code in front of the text to be sent can mention NewBing. But how do we receive messages in real-time after sending a message? Because BingChat cannot immediately respond after we send a message, the official documentation only provides a way to get messages in the current session. I kept searching the official documentation over and over again, and finally, my efforts paid off. I found the SkypeNewMessageEvent and SkypeEditMessageEvent methods (these two methods are at the bottom of the documentation, I didn't notice them because I was blind). The SkypeNewMessageEvent method listens for and retrieves the latest messages, while the SkypeEditMessageEvent method listens for and retrieves the modified messages. Yes, that's right! Skype can modify messages in real-time. At that time, I didn't use the SkypeEditMessageEvent method because when I tested it, I only asked some simple questions and NewBing could answer them in one sentence, so I didn't pay much attention to it. But after multiple tests, I found that NewBing always stops talking halfway, which puzzled me. I suddenly realized the SkypeEditMessageEvent, which can listen in real-time for message modifications and return the modified content of the message.

Final Result#

After adding some features, the final result is as follows:

demo

Get the Code#

GitHub Please give it a star if you find it helpful.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.