当前位置: 首页>>代码示例>>C#>>正文


C# IrcDotNet.IrcMessageEventArgs类代码示例

本文整理汇总了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,"");
            }
        }
开发者ID:jonbonne,项目名称:OCTGN,代码行数:28,代码来源:For.cs

示例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));
        }
开发者ID:jonbonne,项目名称:OCTGN,代码行数:7,代码来源:G.cs

示例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++;
            }
        }
开发者ID:IrcDotNet,项目名称:IrcDotNet,代码行数:31,代码来源:MarkovChainTextBot.cs

示例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);
 }
开发者ID:jonbonne,项目名称:OCTGN,代码行数:8,代码来源:Gtc.cs

示例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?
     }
 }
开发者ID:amauragis,项目名称:BofhDotNet,代码行数:8,代码来源:BofhBot.cs

示例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.");
 }
开发者ID:jonbonne,项目名称:OCTGN,代码行数:9,代码来源:Todo.cs

示例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());
                }
            }
        }
开发者ID:jonbonne,项目名称:OCTGN,代码行数:56,代码来源:ChannelBot.cs

示例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);
 }
开发者ID:rexperalta,项目名称:OCTGN,代码行数:10,代码来源:Ver.cs

示例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);
     }
 }
开发者ID:jonbonne,项目名称:OCTGN,代码行数:15,代码来源:H.cs

示例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();
        }
开发者ID:jonbonne,项目名称:OCTGN,代码行数:16,代码来源:Murder.cs

示例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();
 }
开发者ID:rexperalta,项目名称:OCTGN,代码行数:20,代码来源:Die.cs

示例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);
            }
        }
开发者ID:kellyelton,项目名称:OctgnHelpBot,代码行数:38,代码来源:ChannelBot.cs

示例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;
        }
开发者ID:jonbonne,项目名称:OCTGN,代码行数:23,代码来源:Gtc.cs

示例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);
              }
        }
开发者ID:destinygg,项目名称:bot,代码行数:36,代码来源:Program.cs

示例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);
                }
            }
        }
开发者ID:code-n-beer,项目名称:SimoBot,代码行数:20,代码来源:Engine.cs


注:本文中的IrcDotNet.IrcMessageEventArgs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。