本文整理汇总了C#中IrcDotNet.IrcMessageEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# IrcMessageEventArgs类的具体用法?C# IrcMessageEventArgs怎么用?C# IrcMessageEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IrcMessageEventArgs类属于IrcDotNet命名空间,在下文中一共展示了IrcMessageEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessMessage
public void ProcessMessage(IrcMessageEventArgs args, string @from, string message)
{
var wd = Directory.GetCurrentDirectory();
var path = Path.Combine(wd, "Messages");
Directory.CreateDirectory(path);
var fpath = Path.Combine(path, from + ".txt");
if (!File.Exists(fpath))
{
Channel.Message("There are no messages for you, what a surprise.",true);
return;
}
var cur = File.ReadAllLines(fpath);
if (cur.Length == 0)
{
Channel.Message("There are no messages for you, what a surprise.",true);
return;
}
else
{
foreach (var s in cur)
{
Channel.Message(s,true);
Channel.Message("Well that's about it. Now don't you feel special?");
}
File.WriteAllText(fpath,"");
}
}
示例2: ProcessMessage
public void ProcessMessage(IrcMessageEventArgs args, string @from, string message)
{
if(string.IsNullOrWhiteSpace(message))
throw new ArgumentException("I'm not a dummy.");
Channel.Message("http://lmgtfy.com/?q=" + HttpUtility.UrlEncode(message));
}
示例3: OnChannelMessageReceived
protected override void OnChannelMessageReceived(IrcChannel channel, IrcMessageEventArgs e)
{
var client = channel.Client;
if (e.Source is IrcUser)
{
// Train Markov generator from received message text.
// Assume it is composed of one or more coherent sentences that are themselves are composed of words.
var sentences = e.Text.Split(sentenceSeparators);
foreach (var s in sentences)
{
string lastWord = null;
foreach (var w in s.Split(' ').Select(w => cleanWordRegex.Replace(w, string.Empty)))
{
if (w.Length == 0)
continue;
// Ignore word if it is first in sentence and same as nick name.
if (lastWord == null && channel.Users.Any(cu => cu.User.NickName.Equals(w,
StringComparison.InvariantCultureIgnoreCase)))
break;
markovChain.Train(lastWord, w);
lastWord = w;
this.numTrainingWordsReceived++;
}
markovChain.Train(lastWord, null);
}
this.numTrainingMessagesReceived++;
}
}
示例4: ProcessMessage
public void ProcessMessage(IrcMessageEventArgs args, string @from, string message)
{
if (!File.Exists("gtc.txt")) File.Create("gtc.txt").Close();
var numstr = File.ReadAllText("gtc.txt");
int num = 0;
int.TryParse(numstr, out num);
Channel.Message("GTC=" + num,true);
}
示例5: OnChannelMessageReceived
protected override void OnChannelMessageReceived(IrcChannel channel, IrcMessageEventArgs e)
{
var client = channel.Client;
if (e.Source is IrcUser)
{
// TODO: keep log of recent chats?
}
}
示例6: ProcessMessage
public void ProcessMessage(IrcMessageEventArgs args, string @from, string message)
{
if (!File.Exists("todo.txt")) File.Create("todo.txt").Close();
if(string.IsNullOrWhiteSpace(message))throw new ArgumentException("You summoned me for nothing?");
var fstr = File.ReadAllLines("todo.txt").ToList();
fstr.Add(from + ": " + message);
File.WriteAllLines("todo.txt",fstr);
Channel.Message("I'll jot that down asshole.");
}
示例7: ChannelOnMessageReceived
private void ChannelOnMessageReceived(object sender, IrcMessageEventArgs ircMessageEventArgs)
{
if (ircMessageEventArgs.Source.Name == "botctgn") return;
var commands = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(x => x.GetModules())
.SelectMany(x => x.GetTypes())
.Where(x => x.GetInterfaces().Any(y => y == typeof(ICommand)))
.ToList();
var fullMess = ircMessageEventArgs.Text;
var from = ircMessageEventArgs.Source.Name;
if (string.IsNullOrWhiteSpace(fullMess)) return;
if (!fullMess.StartsWith("."))
{
foreach (var com in commands)
{
var ac = Activator.CreateInstance(com) as ICommand;
ac.CanProcessMessage(ircMessageEventArgs, fullMess);
}
}
else
{
fullMess = fullMess.Substring(1);
var firstSpace = fullMess.IndexOf(' ');
if (firstSpace <= 0) firstSpace = fullMess.Length;
var comstr = fullMess.Substring(0, firstSpace).Trim();
var command = commands.FirstOrDefault(x => x.Name.ToLower() == comstr);
if (command == null)
{
Message("I don't understand '" + ircMessageEventArgs.Text + "'",true);
return;
}
var messstr = fullMess.Substring(comstr.Length).Trim();
try
{
var ac = Activator.CreateInstance(command) as ICommand;
ac.Channel = this;
ac.ProcessMessage(ircMessageEventArgs,from,messstr);
}
catch (ArgumentException e)
{
this.Message("Paradox: " + e.Message,true);
}
catch(Exception e)
{
Message("Something blew up...I'm scared.",true);
this.Message(e.ToString());
}
}
}
示例8: ProcessMessage
public void ProcessMessage(IrcMessageEventArgs args, string @from, string message)
{
var ret =new WebClient().DownloadString(
"https://raw.github.com/kellyelton/OCTGN/master/octgnFX/Octgn/CurrentReleaseVersion.txt").Trim();
Channel.Message("Current live version is " + ret,true);
ret =
new WebClient().DownloadString(
"https://raw.github.com/kellyelton/OCTGN/master/octgnFX/Octgn/CurrentTestVersion.txt").Trim();
Channel.Message("Current test version is " + ret,true);
}
示例9: ProcessMessage
public void ProcessMessage(IrcMessageEventArgs args, string @from, string message)
{
var commands = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(x => x.GetModules())
.SelectMany(x => x.GetTypes())
.Where(x => x.GetInterfaces().Any(y => y == typeof(ICommand)))
.ToList();
Channel.Message("====================Help====================",true);
foreach (var c in commands)
{
var com = (ICommand)Activator.CreateInstance(c);
var argstring = string.Join(" ", com.Arguments.Select(x => "{" + x + "}"));
Channel.Message("." + c.Name.ToLower() + " " + argstring + " - " + com.Usage,true);
}
}
示例10: ProcessMessage
public void ProcessMessage(IrcMessageEventArgs args, string @from, string message)
{
if(string.IsNullOrWhiteSpace(message))
throw new ArgumentException("Yeah...so...I'll just murder no one then...");
if(message.ToLower() == "kellyelton")
throw new ArgumentException("I can't murder my creator!");
if(message.ToLower() == Channel.Channel.Client.LocalUser.NickName.ToLower())
throw new ArgumentException("That would be suicide, not murder!");
new Task(() =>
{
Channel.Channel.Kick(message, from + " Told me to do it! I didn't mean it, I swear!");
Thread.Sleep(2000);
Channel.Message("Well that felt good.");
}).Start();
}
示例11: ProcessMessage
public void ProcessMessage(IrcMessageEventArgs args, string @from, string message)
{
if (from.ToLower() != "kellyelton")
{
Channel.Message("You wished " + from);
return;
}
Channel.Message("I will never forget this " + from);
var task = new Task(
() =>
{
Thread.Sleep(5000);
this.Channel.Channel.Leave("WHY DOES NOBODY LOVE ME FAAAAAWK!");
Thread.Sleep(5000);
Program.client.Quit("WAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
Thread.Sleep(5000);
Program.client.Disconnect();
});
task.Start();
}
示例12: ChannelOnMessageReceived
private void ChannelOnMessageReceived(object sender, IrcMessageEventArgs ircMessageEventArgs)
{
if (ircMessageEventArgs.Source.Name == "GaryBot") return;
//if (ircMessageEventArgs.Text.Trim().EndsWith("?"))
//{
// this.Message("http://lmgtfy.com/?q=" + HttpUtility.UrlEncode(ircMessageEventArgs.Text));
//}
return;
var from = ircMessageEventArgs.Source.Name.ToLower();
var num = random.Next(0, 100);
if (from.Contains(Who.ToLower()) || from.Contains("brine") || num > 55)
{
noDb0Counter = 0;
dboResponded = true;
var reply = "";
while (String.IsNullOrWhiteSpace(reply))
{
try
{
reply = Bot.Think(ircMessageEventArgs.Text);
}
catch (Exception)
{
try
{
Bot = new ChatterBotAPI.ChatterBotFactory().Create(ChatterBotType.CLEVERBOT).CreateSession();
}
catch
{
}
}
}
this.Message(reply);
}
}
示例13: CanProcessMessage
public bool CanProcessMessage(IrcMessageEventArgs args, string message)
{
if(args.Source.Name.ToLower().Contains("grave"))
if (message.ToLower().Contains(":p"))
{
int count = 0, n = 0;
while ((n = message.ToLower().IndexOf(":p", n, StringComparison.InvariantCulture)) != -1)
{
n += ":p".Length;
++count;
}
if (!File.Exists("gtc.txt")) File.Create("gtc.txt").Close();
var numstr = File.ReadAllText("gtc.txt");
int num = 0;
int.TryParse(numstr, out num);
num+= count;
File.WriteAllText("gtc.txt", num.ToString());
return true;
}
return false;
}
示例14: IrcClient_Channel_MessageReceived
private static void IrcClient_Channel_MessageReceived(object sender, IrcMessageEventArgs e)
{
var channel = (IrcChannel) sender;
if (e.Source is IrcUser) {
var user = (IrcUser) e.Source;
var hostName = user.HostName;
var text = e.Text;
if (user.HostName == "head.against.the.heart" && e.Text[0] == '~') {
hostName = "heart.against.the.head";
text = e.Text.Substring(1);
}
Console.WriteLine("[{0}]({1}): {2}.", channel.Name, e.Source.Name, text);
if (text[0] == '<') {
return;
}
var meDetection = new Regex(@"\u0001ACTION (.*)\u0001").Match(text);
if (meDetection.Success) {
text = $"/me {meDetection.Groups[1]}";
}
if (PrivateConstants.HostNameToDggKey.ContainsKey(hostName)) {
if (!_hostNameToWebSockets.ContainsKey(hostName)) {
_hostNameToWebSockets.Add(hostName, new WebSocketClient(PrivateConstants.HostNameToDggKey[hostName]));
SendToEcho($"Connecting {user.NickName} with {hostName}...");
_hostNameToWebSockets[hostName].Run(doNothingProcessor);
Thread.Sleep(3000); // TODO fix, this is hacky
}
_hostNameToWebSockets[hostName].Visit(new PublicMessage(text));
}
} else {
Console.WriteLine("[{0}]({1}) Message: {2}.", channel.Name, e.Source.Name, e.Text);
}
}
示例15: handleRegexes
private void handleRegexes(object sender, IrcMessageEventArgs e, IrcClient client)
{
string channel = "";
foreach (var messageTarget in e.Targets)
{
if (messageTarget is IrcChannel)
{
channel = messageTarget.Name;
break;
}
}
foreach (var regex in handlers.regexes)
{
if (regex.Key.IsMatch(e.Text))
{
regex.Value(client, channel, e.Source as IrcUser, e.Text);
}
}
}