Skype BOT C#无法正常运行

时间:2015-03-27 20:39:06

标签: c# bots skype skype4com

我正在用C#制作一个Skype机器人,但我遇到了问题。它不会读取我自己的命令,只读取其他命令。

当我添加类似"!Resolve(用户名)"它使代码全部被窃听起来,我的意思是它只是在我启动它时崩溃了。

有人可以看看是否有任何重大问题。

private Skype skype;
    private const string trigger = "!";
    private const string nick = "The OG Bot";

这个

private string ProcessCommand(string str)
    {
        string result;
        switch (str)
        {
            case "resolve":
                result = "Currently Not Working Will Fix Soon.";
                break;
            case "help":
                result = "Here are some commands you can run. \n !resolve \n !date \n !time \n !who \n !swag \n !ip";
                break;
            case "date":
                result = "Current Date is: " + DateTime.Now.ToLongDateString();
                break;
            case "time":
                result = "Current Time is: " + DateTime.Now.ToLongTimeString();
                break;
            case "who":
                result = "This API was created by TehMerkMods";
                break;
            case "ip":
                result = new WebClient().DownloadString("http://icanhazip.com");
                break;
            case "swag":
                result = "(mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) ";
                break;
            default:
                result = "Sorry, I do not recognize your command";
                break;
        }

        return result;
    }

最后

private void skype_MessageStatus(ChatMessage msg, TChatMessageStatus status)
    {
        if (TChatMessageStatus.cmsRead == status)
        {
            return;
        }

        if (msg.Body.IndexOf(trigger) == 0 && TChatMessageStatus.cmsReceived == status)
        {
            string command = msg.Body.Remove(0, trigger.Length).ToLower();
            skype.SendMessage(msg.Sender.Handle, nick + " : " + ProcessCommand(command));
        }
    }

2 个答案:

答案 0 :(得分:1)

您只是收到了',您需要发送'还

示例:

if (TChatMessageStatus.cmsReceived Or Status = TChatMessageStatus.cmsSent)

答案 1 :(得分:0)

在代码的最后一部分中只有一个if语句,它只查找TChatMessageStatus.cmsReceived。

,当您发送邮件时,此声明永远不会成立。

至于程序崩溃......你需要提供更多信息。

相关问题