c#Skype应用程序在触发时向当前聊天室发送文本
好吧,我正在制作一个Skype工具箱程序,它可以做很多事情,但我在使用Aui时遇到了麻烦 该程序的这一部分旨在查看与人聊天时发送的命令并打印文本。例如,如果你说!胖子在和别人聊天时,会写“哟胖子” 我在网上发现了这段代码:c#Skype应用程序在触发时向当前聊天室发送文本,c#,winforms,skype,visual-c#-express-2010,skype4com,C#,Winforms,Skype,Visual C# Express 2010,Skype4com,好吧,我正在制作一个Skype工具箱程序,它可以做很多事情,但我在使用Aui时遇到了麻烦 该程序的这一部分旨在查看与人聊天时发送的命令并打印文本。例如,如果你说!胖子在和别人聊天时,会写“哟胖子” 我在网上发现了这段代码: using System; using System.Windows.Forms; using SKYPE4COMLib; // Our COM library namespace SkypeBing { public partial class Form1 : F
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如果您需要更多信息或希望成为其发展的一部分,请直接询问
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);
这是你能做什么的基本轮廓,从那里很容易扩展。希望这能把事情弄清楚