0

好的,所以我正在制作一个可以做很多事情的 Skype 工具箱程序,但是我在使用 Aui 时遇到了问题。

该程序的这一部分旨在查看在与人聊天中发送的命令并打印文本。例如,如果你在和某人聊天时说 !fatty,它会写成“yo fat boy”。

我在网上发现了这段代码:

using System;
using System.Windows.Forms;
using SKYPE4COMLib; // Our COM library

namespace SkypeBing
{
    public partial class Form1 : Form
    {
        private Skype skype;
        private const string trigger = "!"; // Say !help
        private const string nick = "Skype Admin";

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            skype = new Skype();
            // Use skype protocol version 7 
            skype.Attach(7, false);
            // Listen 
            skype.MessageStatus +=
              new _ISkypeEvents_MessageStatusEventHandler(skype_MessageStatus);
        }
        private void skype_MessageStatus(ChatMessage msg,
                     TChatMessageStatus status)
        {
            // Proceed only if the incoming message is a trigger
            if (msg.Body.IndexOf(trigger) == 0)
            {
                // Remove trigger string and make lower case
                string command = msg.Body.Remove(0, trigger.Length).ToLower();

                // Send processed message back to skype chat window
                skype.SendMessage(msg.Sender.Handle, nick +
                      " Says: " + ProcessCommand(command));
            }
        }

        private string ProcessCommand(string str)
        {
            string result;
            switch (str)
            {
                case "hello":
                    result = "Hello!";
                    break;
                case "help":
                    result = "Sorry no help available";
                    break;
                case "date":
                    result = "Current Date is: " +
                             DateTime.Now.ToLongDateString();
                    break;
                case "time":
                    result = "Current Time is: " +
                             DateTime.Now.ToLongTimeString();
                    break;
                case "who":
                    result = "It is Praveen, aka NinethSense " +
                             "who wrote this tutorial";
                    break;
                default:
                    result = "Sorry, I do not recognize your command";
                    break;
            }

            return result;
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }
    }
}

但这不起作用,因为它需要发送给用户。我对这个 Aui 很陌生。如果有人对我可以用来正确调用此事件的方法有任何想法,因为在线支持不多,所以我想我会问你超级人。:D 如果您需要更多信息或想参与其开发,请询问。

4

1 回答 1

1
 private void skype_MessageStatus(ChatMessage msg, TChatMessageStatus status)
 {
       if (msg.Body.Contains("faty"))
       {
            skype.SendMessage(msg.Sender.Handle,"Go away fatty!");
       }
  }

skype.MessageStatus += new _ISkypeEvents_MessageStatusEventHandler(skype_MessageStatus);

这就是你可以做什么的基本大纲,它很容易从那里扩展。希望这可以解决问题。

于 2013-08-08T06:20:11.597 回答