【问题标题】:Skype bot (translation from VB) not workingSkype bot(从 VB 翻译)不工作
【发布时间】:2017-06-29 08:47:18
【问题描述】:

我在 youtube 上关注如何创建一个简单的 Skype 机器人的教程。它是用 VB 编写的,由于我的知识有限,我尽力用 C# 重新创建它 我偶然发现了“句柄”,我只能假设它与 C# 中的事件处理程序有关

这是我目前获得的代码,但是当我从另一个 Skype 帐户向自己发送消息时,它没有响应。我已确保接受 Skype 上允许使用 3rd 方软件的小弹出窗口。

public partial class Form1 : Form
{
    Skype oSkype = new Skype();
    string trigger = "!";

    public Form1()
    {
        InitializeComponent();
        oSkype.Attach(7, false);
        oSkype.MessageStatus += new _ISkypeEvents_MessageStatusEventHandler(oSkype_MessageStatus);
    }


    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void oSkype_MessageStatus(ChatMessage pMessage, TChatMessageStatus Status)
    {
        if (Status == TChatMessageStatus.cmsReceived || Status == TChatMessageStatus.cmsSent)
        {
            string msg = pMessage.Body;
            Chat c = pMessage.Chat;

            if (msg.StartsWith(trigger))
            {
                listBox1.Items.Add(DateTime.Now.ToLongTimeString() + ": " + pMessage.Sender.Handle + " sent you a message");
                msg = msg.Remove(0, 1).ToLower();


                if (msg == "test")
                {
                    c.SendMessage("Test");
                }
                else
                {
                    c.SendMessage("Unrecognizable command.");
                }
            }
        }
    }
}

我所遵循的教程中的代码改为:

oSkype_MessageStatus(pMessage as ChatMessage, Status as TChatMessageStatus) Handles oSkype.MessageStatus

最接近我在 c# 中实现这一点的方法是将 void 添加到 public Form1() 中的事件处理程序中,您可以在我的代码中看到。

提前致谢!

【问题讨论】:

  • 看起来不错。问题不在您发布的代码中。

标签: c# vb.net bots skype


【解决方案1】:

我已经有一段时间没有使用 COM Skype 机器人了,但您的代码似乎还不错。

尽管如此,我建议您转向现代的机器人方法。请查看新的Microsoft Bot Framework

【讨论】:

    【解决方案2】:

    较新的 Skype 版本不支持 Skype4Com 的聊天功能。它们在 2013-2014 年之间的某个地方被弃用了。

    来自 Skype 的博文Feature evolution and support for the Skype Desktop API

    我很高兴地分享,我们将扩展对两个最广泛使用的功能的支持——通话录音和与硬件设备的兼容性——直到我们确定替代选项或淘汰当前的解决方案。 虽然通过第三方应用程序进行聊天,但将不再像之前所说的那样工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-15
      • 2018-11-06
      • 2011-10-05
      • 2015-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多