如何创建主持聊天,然后将联系人添加到创建的聊天中

How to create moderated chat, then add contact to the chat created

如标题所示,我正在尝试创建一个主持聊天,然后将联系人添加到创建的聊天中。

我试过将某人添加到群聊(类似这样):

For Each chat As Chat In Skypattach.BookmarkedChats
If chat.Name = "#my-skype/$baf1ad******" Then
    msg.Chat.SendMessage("Please wait while we add you!)
    chat.SendMessage("/add " & "contact-to-add")
End If
Next

但我需要指定聊天名称,所以暂时无法使用。我有一个我不知道该怎么做的想法,不知道是否可行,还有没有办法创建主持聊天,然后获取创建的聊天的聊天名称?这可以解决我的问题...如果我的问题有任何解决办法,请告诉我。谢谢你的时间。

我很惊讶 chat.SendMessage("/add " & "contact-to-add") 行首先起作用,因为我在使用它时遇到错误。因此,我使用子例程通过 UserCollection 对象添加新成员。当您想添加新成员时,添加到 UserCollection,然后将其传递给 AddMembers() 子例程。

至于聊天名称本身,您不需要它。如果您当场创建聊天,则将其分配给聊天变量。

Imports SKYPE4COMLib


Public Class Form1

Dim skype As Skype
Dim uc As UserCollection
Dim chat As Chat

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    skype = New Skype()
    skype.Attach(7, True)
End Sub


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    uc = New UserCollection()    'Hold the users in a UserCollection obj
    uc.Add(skype.User("echo123"))
    uc.Add(skype.User("otherperson_123123123123121625"))

    chat = skype.CreateChatMultiple(uc)  'Create the chat with the 2 users
    chat.OpenWindow()
    chat.Topic = "test"
    chat.SendMessage("test")
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    'CHECK TO MAKE SURE YOU DON'T TRY AND ADD SAME PERSON TWICE!
    'For some reason, attempting to do so causes errors.
    For Each r As User In uc
        If TextBox1.Text = r.Handle Then
            Return
        End If
    Next
    skype.SendMessage(TextBox1.Text, "Please wait while we add you!")
    uc.Add(skype.User(TextBox1.Text))
    chat.AddMembers(uc)
End Sub
End Class

希望这能解答您的问题并对您有所帮助。