Ejemplo n.º 1
1
        public override void HandleCommand(IList<string> paramList, IrcUser user, bool isIngameCommand)
        {
            int num;
            if (paramList.Count() == 1)
            {
                // display random quote
                Connection.GetData(Data.UrlQuote, "get", jObject =>
                {
                    if ((bool)jObject["success"])
                    {
                        Utils.SendChannel((string)jObject["result"].SelectToken("id") + ": " +
                                          (string)jObject["result"].SelectToken("quote"));
                    }
                    else
                    {
                        Utils.SendChannel("No quotes found.");
                    }
                }, Utils.HandleException);
            }
            else if (paramList[1] == "add")
            {
                if (isIngameCommand == false)
                {
                    var quote = "";
                    for (var l = 2; l < paramList.Count(); l++)
                    {
                        quote = quote + paramList[l] + " ";
                    }

                    Connection.GetData(string.Format(Data.UrlQuoteAdd, user.Nick, user.Hostmask, quote.Trim()),
                        "get", jObject => Utils.SendChannel(string.Format("Quote #{0} has been added.", jObject["result"].SelectToken("id"))), Utils.HandleException);
                }
                else
                {
                    Utils.SendChannel("This command is restricted to the IRC channel only.");
                }
            }
            else if (int.TryParse(paramList[1], out num))
            {
                Connection.GetData(string.Format(Data.UrlQuoteSpecific, num), "get", jObject =>
                {
                    if ((bool)jObject["success"])
                    {
                        Utils.SendChannel((string)jObject["result"].SelectToken("quote"));
                    }
                    else
                    {
                        Utils.SendChannel("Specific quote not found.");
                    }
                }, Utils.HandleException);
            }
            else
            {
                Utils.SendChannel("Usage: !quote add <message>");
            }
        }
Ejemplo n.º 2
1
        public DccReceiveClient(Dcc dcc, IrcUser user, Socket sock, IPEndPoint addr, FileInfo file, long totalSize,
								TimeSpan timeout)
            : base(dcc, user, sock, file, 0, totalSize)
        {
            m_remoteAddr = addr;
            // m_sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 10000)
            m_timeoutTimer = new Timer((int)timeout.TotalMilliseconds);
            m_timeoutTimer.Elapsed += OnTimeout;
            m_timeoutTimer.AutoReset = false;
            m_timeoutTimer.Start();
        }
Ejemplo n.º 3
0
        private void StartIrc()
        {
            var user = new IrcUser("");
            if (Properties.Settings.Default.nickserv == string.Empty)
                user = new IrcUser("twitchplaysagame", "twitchplaysagame");
            else
                user = new IrcUser(Properties.Settings.Default.user, Properties.Settings.Default.user);
            client = new IrcClient(Properties.Settings.Default.server, user);
            client.NetworkError += (s, e) => WriteConsole("Error: " + e.SocketError);

            client.ChannelMessageRecieved += (s, e) =>
            {
                ParseInput(e.PrivateMessage.User.Nick + ":" + e.PrivateMessage.Message);
            };
            client.ConnectionComplete += (s, e) =>
            {
                client.SendRawMessage("PRIVMSG {0} :{1}", "nickserv", "identify " + Properties.Settings.Default.nickserv);
                client.Channels.Join(Properties.Settings.Default.room);
                WriteConsole("Connected");
            };
            client.ConnectAsync();

            this.WriteConsole("Starting irc service");
            started = true;
            buttonStart.Text = "Stop";
        }
Ejemplo n.º 4
0
 public override void HandleCommand(IList<string> paramList, IrcUser user, bool isIngameCommand)
 {
     if (Utils.IsOp(user.Nick)|Utils.IsAdmin(user.Nick))
     {
         int i;
         // check if params number more than 4, if the pack length is less than 5 and the server is a number
         if (paramList.Count == 3 && paramList[1].Length < 5 && Int32.TryParse(paramList[2], out i))
         {
             Connection.GetData(String.Format(Data.UrlCrashLog, paramList[1], paramList[2]), "get", jObject =>
             {
                 if ((bool) jObject["success"])
                 {
                     Utils.SendChannel((string) jObject["result"]["response"]);
                 }
                 else
                 {
                     Utils.SendChannel("Failed to push crash log to pastebin. Please try again later.");
                 }
             }, Utils.HandleException);
         }
         else
         {
             Utils.SendChannel("Usage: !log <pack> <server_id>");
         }
     }
     else
     {
         Utils.SendChannel(Data.MessageRestricted);
     }
 }
Ejemplo n.º 5
0
    private static void Main(){
      var ircUser = new IrcUser(Conf.Nick, Conf.User);
      var client = new IrcClient(Conf.Server, ircUser);
      var ChatBot = new BotAgent();
      ChatBot.Initialise();

      client.ConnectionComplete += (s, e) => {
        foreach (string chan in Conf.Channels)
          client.JoinChannel(chan);
      };

      client.ChannelMessageRecieved += (s, e) => {
        var source = e.PrivateMessage.Source;
        var channel = client.Channels[source];
        var message = e.PrivateMessage.Message;

        var urls = URLTitle.GetURLs(message);
        if (urls.Count != 0){
          var responseTitle = URLTitle.GetTitle(urls[0]);
          channel.SendMessage(responseTitle);
        }
        else{
          var query = ChatBot.Query(message);
          var response = ChatBot.Reply(query);
          Log(message, response.Output, Conf.Nick, source);
          channel.SendMessage(response.Output);
        }
      };

      client.NetworkError += (s, e) =>
        Console.WriteLine("Error: {0}", e.SocketError);
 
      client.ConnectAsync();
      while (true);
    }
Ejemplo n.º 6
0
 public KickEventArgs(IrcChannel channel, IrcUser kicker, IrcUser kicked, string reason)
 {
     Channel = channel;
     Kicker = kicker;
     Kicked = kicked;
     Reason = reason;
 }
Ejemplo n.º 7
0
        public override void HandleCommand(IList<string> paramList, IrcUser user, bool isIngameCommand)
        {
            if (!Utils.IsDev(user.Nick)) return;
            //var temp = new int[100];
            //for (var i = 0; i < 100; i++)
            //{
            //    temp[i] = GenerateRandom(0, 5);
            //}

            //var occur = new Dictionary<int, int>();
            //foreach (var item in temp)
            //{
            //    if (occur.ContainsKey(item))
            //    {
            //        occur[item] ++;
            //    }
            //    else
            //    {
            //        occur.Add(item, 1);
            //    }
            //}

            //foreach (var item in occur)
            //{
            //    Console.WriteLine(item.Key + ": " + item.Value);
            //}
        }
Ejemplo n.º 8
0
 public override void HandleCommand(IList<string> paramList, IrcUser user, bool isIngameCommand)
 {
     if (Utils.IsOp(user.Nick) ||
         user.Nick == "DrSmugleaf" ||
         user.Nick == "DrSmugleaf_")
     {
         var random = new Random().Next(0, 2);
         if (paramList.Count > 1)
         {
             switch (paramList[1])
             {
                 case "1":
                     Utils.SendChannel(Data.SmugResponses[0]);
                     break;
                 case "2":
                     Utils.SendChannel(Data.SmugResponses[1]);
                     break;
                 default:
                     Utils.SendChannel(Data.SmugResponses[random]);
                     break;
             }
         }
         else
         {
             Utils.SendChannel(Data.SmugResponses[random]);
         }
     }
     else
     {
         Utils.SendChannel("This command is useless.");
     }
 }
Ejemplo n.º 9
0
 public DccClient(Dcc dcc, IrcUser user)
 {
     m_dcc = dcc;
     m_user = user;
     m_startTime = DateTime.Now;
     m_closed = false;
 }
Ejemplo n.º 10
0
        public override void HandleCommand(IList<string> paramList, IrcUser user, bool isIngameCommand)
        {
            if (Utils.IsOp(user.Nick))
            {
                Connection.GetData(Data.UrlTps, "get", jObject =>
                {
                    string filter;
                    try
                    {
                        filter = paramList[1];
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        filter = "";
                    }

                    var outputString = "";
                    const string delimiter = ", ";
                    outputString = String.IsNullOrEmpty(filter) ? jObject["result"].Select(row => JsonConvert.DeserializeObject<JsonTps>(row.ToString())).Aggregate(outputString, (current, tps) => current + (Utils.FormatText(tps.Server.ToUpper(), Colors.Bold) + ":" + Utils.FormatTps(tps.Tps) + delimiter)) : jObject["result"].Select(row => JsonConvert.DeserializeObject<JsonTps>(row.ToString())).Where(tps => tps.Server.Contains(paramList[1])).Aggregate(outputString, (current, tps) => current + (Utils.FormatText(tps.Server.ToUpper(), Colors.Bold) + ":" + Utils.FormatTps(tps.Tps) + delimiter));
                    if (!String.IsNullOrEmpty(outputString))
                    {
                        Utils.SendChannel(outputString.Substring(0, outputString.Length - delimiter.Length));
                    }
                }, Utils.HandleException);
            }
            else
            {
                Utils.SendChannel(Data.MessageRestricted);
            }
        }
Ejemplo n.º 11
0
 public override void HandleCommand(IList<string> paramList, IrcUser user, bool isIngameCommand)
 {
     if (Utils.IsOp(user.Nick))
     {
         if (paramList.Count < 3)
         {
             Utils.SendNotice("Usage: !announce <time in seconds> <repeats> <message>", user.Nick);
         }
         else
         {
             var msg = "";
             var timeTick = Convert.ToInt32(paramList[1])*1000;
             var timeCount = Convert.ToInt32(paramList[2]);
             if (timeTick == 0) return;
             Program.AnnounceTimer.Interval = timeTick;
             GC.KeepAlive(Program.AnnounceTimer);
             for (var i = 3; i < paramList.Count; i++)
             {
                 msg = msg + paramList[i] + " ";
             }
             Instances.Announcement.AnnounceMsg = msg;
             Instances.Announcement.AnnounceTimes = timeCount;
             Program.AnnounceTimer.Enabled = true;
         }
     }
     else
     {
         Utils.SendChannel(Data.MessageRestricted);
     }
 }
Ejemplo n.º 12
0
 internal void OnNewUser(IrcUser user)
 {
     if (user.IrcClient.AutoResolveAuth && Authenticator != null)
     {
         ResolveAuth(user);
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CtcpErrorMessageReceivedEventArgs"/> class,
 /// specifying that no error occurred.
 /// </summary>
 /// <param name="noErrorMessage">The message indicating that no error occurred.</param>
 public CtcpErrorMessageReceivedEventArgs(IrcUser user, string noErrorMessage)
     : base(user)
 {
     this.ErrorOccurred = false;
     this.FailedQuery = null;
     this.ErrorMessage = noErrorMessage;
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CtcpErrorMessageReceivedEventArgs"/> class,
 /// specifying the query that failed with an error message.
 /// </summary>
 /// <param name="failedQuery">A string containing the query that failed.</param>
 /// <param name="errorMessage">The message describing the error that occurred for the remote user.</param>
 public CtcpErrorMessageReceivedEventArgs(IrcUser user, string failedQuery, string errorMessage)
     : base(user)
 {
     this.ErrorOccurred = true;
     this.FailedQuery = failedQuery;
     this.ErrorMessage = errorMessage;
 }
Ejemplo n.º 15
0
 public DarkChat()
 {
     loadConfig();
     DarkLog.Debug(String.Format("[DarkChat] initialized version {0}", PLUGIN_VER));
     ircUser = new IrcUser(settings.Nick, settings.Ident, settings.NickServ, settings.RealName);
     ircClient = new IrcClient(settings.Server, ircUser);
 }
Ejemplo n.º 16
0
 public IrcMessage(IrcUser sender, string channel, string message, bool action = false)
 {
     Sender = sender;
     Channel = channel;
     Message = message;
     Action = action;
 }
Ejemplo n.º 17
0
        public override void HandleCommand(IList<string> paramList, IrcUser user, bool isIngameCommand)
        {
            int i;
            // check if the params number 4, that the number/sides are integers, and that number and sides are both greater than 0
            if (paramList.Count() == 3 && Int32.TryParse(paramList[1], out i) && Int32.TryParse(paramList[2], out i) &&
                (Int32.Parse(paramList[1]) > 0) && (Int32.Parse(paramList[2]) > 0) && (Int32.Parse(paramList[1]) <= 4) &&
                (Int32.Parse(paramList[2]) <= 100))
            {
                var dice = Int32.Parse(paramList[1]);
                var sides = Int32.Parse(paramList[2]);
                var random = new Random();

                var diceList = new List<int>();
                for (var j = 0; j < dice; j++)
                {
                    diceList.Add(random.Next(1, sides));
                }

                var outputString = String.Format("Rolling a {0} sided die, {1} time{2}: {3}", sides, dice,
                    (dice > 1) ? "s" : "", diceList.Aggregate("", (current, roll) => current + roll + " ").Trim());
                Utils.SendChannel(outputString);
            }
            else
            {
                Utils.SendChannel("Usage: !dice <number 1-4 > <sides 1 - 100>");
            }
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Returns a IrcUser based on a prefix.
 /// </summary>
 /// <param name="prefix">The prefix.</param>
 /// <returns>The resulting IrcUser</returns>
 public static IrcUser FromPrefix(string prefix)
 {
     string nick = prefix.Substring(0, prefix.IndexOf('!'));
     IrcUser user = new IrcUser();
     user.name = nick;
     return user;
 }
Ejemplo n.º 19
0
 public DccTransferClient(Dcc dcc, IrcUser user, FileInfo file, long startPos, long totalLength)
     : base(dcc, user)
 {
     m_file = file;
     m_startPos = startPos;
     m_totalLength = totalLength;
     Dcc.AddTransferClient(this);
 }
Ejemplo n.º 20
0
        protected override void Load()
        {
            IrcUser user = new IrcUser(this.nick, "testing", this.password);

            this.Client = new IrcClient(this.servaddy, user);
            this.Client.ChannelMessageRecieved += ChannelMessageRecieved;
            this.Client.ConnectionComplete     += ConnectionComplete;
            this.Client.UserJoinedChannel      += UserJoinedChannel;
        }
Ejemplo n.º 21
0
        public void GetUserModes_NotNull_FiveModes()
        {
            var user   = new IrcUser("~&@%+aji", "user");
            var client = new IrcClient("irc.address", user);

            var userModes = client.ServerInfo.GetModesForNick(user.Nick);

            Assert.True(userModes.Count == 5);
        }
Ejemplo n.º 22
0
        public void GetUserModes_IsNull()
        {
            var user   = new IrcUser("aji", "user");
            var client = new IrcClient("irc.address", user);

            var userModes = client.ServerInfo.GetModesForNick(user.Nick);

            Assert.True(userModes.Count == 0);
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CtcpMessage"/> structure.
 /// </summary>
 /// <param name="source">The source of the message.</param>
 /// <param name="targets">A list of the targets of the message.</param>
 /// <param name="tag">The tag of the message.</param>
 /// <param name="data">The data contained by the message, or <see langword="null"/> for no data.</param>
 /// <param name="isResponse"><see langword="true"/> if the message is a response to another message;
 /// <see langword="false"/>, otherwise.</param>
 public CtcpMessage(IrcUser source, IList <IIrcMessageTarget> targets, string tag, string data,
                    bool isResponse)
 {
     this.Source     = source;
     this.Targets    = targets;
     this.Tag        = tag;
     this.Data       = data;
     this.IsResponse = isResponse;
 }
Ejemplo n.º 24
0
        public void GetUserModes_NotNull_OneMode()
        {
            IrcUser   user   = new IrcUser("+aji", "user");
            IrcClient client = new IrcClient("irc.address", user);

            var userModes = client.ServerInfo.GetModesForNick(user.Nick);

            Assert.IsTrue(userModes.Count == 1);
        }
Ejemplo n.º 25
0
 public static void HandleQuit(IrcClient client, IrcMessage message)
 {
     var user = new IrcUser(message.Prefix);
     if (client.User.Nick != user.Nick)
     {
         client.Users.Remove(user);
         client.OnUserQuit(new UserEventArgs(user));
     }
 }
Ejemplo n.º 26
0
        private static PartAction CreatePart(UserManager users, MsgEventArgs msg)
        {
            var message = msg.Data.Length > 1 ? msg.Data[1] : null;

            return(new PartAction(msg.Data[0])
            {
                Message = message,
                User = IrcUser.GetOrCreate(users, msg.Meta)
            });
        }
Ejemplo n.º 27
0
 public DccChatClient GetChatClient(IrcUser user)
 {
     if (user != null)
     {
         DccChatClient client;
         chatCons.TryGetValue(user, out client);
         return(client);
     }
     return(null);
 }
Ejemplo n.º 28
0
        private IrcUserChannelModePair GetPair(IrcUser user)
        {
            var pair = this._items.FirstOrDefault(p => p.User == user);

            if (pair == null)
            {
                throw new KeyNotFoundException("The specified IrcUser is not in the collection.");
            }
            return(pair);
        }
Ejemplo n.º 29
0
        public void TestIrcUser()
        {
            const string path    = "[email protected]";
            var          talker  = new Talker(null, null, null);
            var          ircUser = IrcUser.GetOrCreate(talker.Users, path);

            Assert.AreEqual("hello", ircUser.Nick);
            Assert.AreEqual("~world", ircUser.Name);
            Assert.AreEqual("herpa.derp", ircUser.Host);
        }
Ejemplo n.º 30
0
        public void CompleteAuth(string redditUser, IrcUser ircUser)
        {
            redditUser = redditUser.ToLower();

            if (AuthPending(redditUser))
            {
                _auth.Remove(redditUser);
            }
            _user.SendMessage("ChanServ", String.Format(ModAddFormat, _modChannel.Name, ircUser.NickName));
        }
Ejemplo n.º 31
0
        public static void HandleQuit(IrcClient client, IrcMessage message)
        {
            var user = new IrcUser(message.Prefix);

            if (client.User.Nick != user.Nick)
            {
                client.Users.Remove(user);
                client.OnUserQuit(new UserEventArgs(user));
            }
        }
Ejemplo n.º 32
0
 /// <summary>
 /// Returns an array of DccTransferClients that are established with the corresponding user.
 /// </summary>
 public List <DccTransferClient> GetTransferClients(IrcUser user)
 {
     if (user != null)
     {
         List <DccTransferClient> clients;
         transferCons.TryGetValue(user, out clients);
         return(clients);
     }
     return(null);
 }
Ejemplo n.º 33
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            // Facilities
            container.AddFacility <LoggingFacility>(f => f.LogUsing <Log4netFactory>().WithConfig("log4net.xml"));
            container.AddFacility <StartableFacility>(f => f.DeferredStart());

            container.Install(new WebInstaller());

            var ircClientMock = new Mock <IIrcClient>();

            ircClientMock.Setup(x => x.ExtBanTypes).Returns("a");
            ircClientMock.Setup(x => x.ExtBanDelimiter).Returns("$");
            ircClientMock.Setup(x => x.Nickname).Returns("EyeInTheSkyBot");
            ircClientMock.Setup(x => x.ClientName).Returns("Freenode");

            var ircChannels = new Dictionary <string, IrcChannel>();
            var chan        = new IrcChannel("##stwalkerster-development");

            ircChannels.Add(chan.Name, chan);
            ircClientMock.Setup(x => x.Channels).Returns(ircChannels);

            IrcUser        user;
            IrcChannelUser ircChannelUser;

            user                = IrcUser.FromPrefix("stwalkerster!test@user/.", ircClientMock.Object);
            user.Account        = "stwalkerster";
            user.SkeletonStatus = IrcUserSkeletonStatus.Full;
            ircChannelUser      = new IrcChannelUser(user, chan.Name);
            chan.Users.Add(user.Nickname, ircChannelUser);


            user                = IrcUser.FromPrefix("chanmember!test@user/.", ircClientMock.Object);
            user.Account        = "chanmember";
            user.SkeletonStatus = IrcUserSkeletonStatus.Full;
            ircChannelUser      = new IrcChannelUser(user, chan.Name);
            chan.Users.Add(user.Nickname, ircChannelUser);

            user                    = IrcUser.FromPrefix("chanop!test@user/.", ircClientMock.Object);
            user.Account            = "chanop";
            user.SkeletonStatus     = IrcUserSkeletonStatus.Full;
            ircChannelUser          = new IrcChannelUser(user, chan.Name);
            ircChannelUser.Operator = true;
            chan.Users.Add(user.Nickname, ircChannelUser);

            container.Register(
                // Main application
                Component.For <IApplication>().ImplementedBy <Launch>(),
                Classes.FromAssemblyNamed("EyeInTheSky").InNamespace("EyeInTheSky.Services").WithServiceAllInterfaces(),
                Classes.FromAssemblyNamed("EyeInTheSky").InNamespace("EyeInTheSky.Services.ExternalProviders").WithServiceAllInterfaces(),
                Classes.FromAssemblyNamed("EyeInTheSky").InNamespace("EyeInTheSky.Services.Email").WithServiceAllInterfaces(),
                Component.For <IIrcClient>().Instance(ircClientMock.Object)
                );

            container.Install(Configuration.FromXmlFile("alert-templates.xml"));
        }
Ejemplo n.º 34
0
        private TwitterBotUser GetTwitterBotUser(IrcUser ircUser)
        {
            var twitterUser = this.twitterUsers.SingleOrDefault(tu => tu.IrcUser == ircUser);

            if (twitterUser == null)
            {
                throw new InvalidOperationException(string.Format(
                                                        "User '{0}' is not logged in to Twitter.", ircUser.NickName));
            }
            return(twitterUser);
        }
Ejemplo n.º 35
0
 string IPlugin.InvokeWithMessage(string source, string message, ref IrcClient client)
 {
     if (message.StartsWith(".whois "))
     {
         string user = message.Split(new char[] { ' ' }, 2)[1];
         client.RfcWhois(user);
         IrcUser u = client.GetIrcUser(user);
         return(String.Format("{0}!{1}@{2}, Away: {3}, Oper: {4}, Realname: {5}", u.Nick, u.Ident, u.Host, u.IsAway, u.IsIrcOp, u.Realname));
     }
     return(null);
 }
Ejemplo n.º 36
0
        public void GetUserModes_NotNull_FourModes()
        {
            IrcClient client;
            IrcUser   user = new IrcUser(client, "&@%+aji", "user");

            client = new IrcClient("irc.address", user);

            var userModes = client.ServerInfo.GetModesForNick(user.Nick);

            Assert.IsTrue(userModes.Count == 4);
        }
Ejemplo n.º 37
0
 internal DccReceiveArgs(IrcUser user, string filename, IPEndPoint remoteEndPoint, long size)
 {
     User            = user;
     FileName        = filename;
     DestinationFile = filename;
     DestinationDir  = "";
     RemoteEndPoint  = remoteEndPoint;
     Size            = size;
     Accept          = Dcc.AcceptTransfer;
     Timeout         = TimeSpan.FromMinutes(1);
 }
Ejemplo n.º 38
0
 /// <summary>
 /// Gets the <see cref="IrcChannelUserModes"/> of the specified <see cref="IrcUser"/>.
 /// </summary>
 /// <param name="index">The <see cref="IrcUser"/>.</param>
 /// <returns>The <see cref="IrcChannelUserModes"/> of the specified <see cref="IrcUser"/>.</returns>
 public IrcChannelUserModes this[IrcUser index]
 {
     get
     {
         return(this.GetPair(index).Mode);
     }
     internal set
     {
         this.GetPair(index).Mode = value;
     }
 }
Ejemplo n.º 39
0
        public PrivateMessage(IrcMessage message)
        {
            Source = message.Payload.Remove(message.Payload.IndexOf(' '));
            Message = message.Payload.Substring(message.Payload.IndexOf(':') + 1);

            User = new IrcUser(message.Prefix);
            if (Source.StartsWith("#"))
                IsChannelMessage = true;
            else
                Source = User.Nick;
        }
Ejemplo n.º 40
0
        public override void HandleCommand(IList<string> paramList, IrcUser user, bool isIngameCommand)
        {
            if (Utils.IsOp(user.Nick))
            {
                if (paramList.Count() == 1)
                {
                    Utils.SendNotice("Usage: !mcb <name> <optional:number>", user.Nick);
                }
                else
                {
                    Connection.GetPlayerLookup(paramList[1], bans =>
                    {
                        if (bans.Local != null && bans.Local.Any())
                        {
                            var limit = 1;
                            int i;
                            if (paramList.Count() == 3 && Int32.TryParse(paramList[2], out i))
                            {
                                // a count is given
                                limit = int.Parse(paramList[2]);
                            }

                            for (var j = 0; j < limit; j++)
                            {
                                var localBan =
                                    bans.Local[j].Replace("\r\n", "")
                                        .Replace("\r", "")
                                        .Replace("\n", "")
                                        .Replace("\0", "")
                                        .Split(' ');

                                var banReason = "";
                                for (var k = 4; k < localBan.Count(); k++)
                                {
                                    banReason += localBan[k] + " ";
                                }

                                Utils.SendNotice(
                                    string.Concat("Server: ", localBan[2], ", Reason: ",
                                        Utils.Truncate(banReason.Trim(), 25), " URL: ", "http://www.mcbans.com/ban/" + localBan[1]), user.Nick);
                            }
                        }
                        else
                        {
                            Utils.SendNotice("This player does not have any local bans.", user.Nick);
                        }
                    }, Utils.HandleException);
                }
            }
            else
            {
                Utils.SendChannel(Data.MessageRestricted);
            }
        }
Ejemplo n.º 41
0
 protected override void OnPart(IrcUser user, IrcChannel chan, string reason)
 {
     if (user == Me)
     {
         Console.WriteLine("({0}) <IRC Interface> * Bot parts channel {1}", DateTime.Now.ToString("hh:mm"), chan.Name);
     }
     else
     {
         Console.WriteLine("({0}) <IRC Interface> * {1} parts channel {2}", DateTime.Now.ToString("hh:mm"), user.Nick, chan.Name);
     }
 }
Ejemplo n.º 42
0
        protected override void OnMessage(Channel channel, IrcUser from, string message)
        {
            //Due to Twitch architecture, a user can send a message before a JOIN.
            if (!_userDatabase.ContainsUser(from.Nick))
            {
                OnJoin(channel, from.Nick);
            }

            SendLastVisited(from.Nick);
            _statistics.UpdateOnMessage(from.Nick, message);
        }
Ejemplo n.º 43
0
 internal DccReceiveArgs(IrcUser user, string filename, IPEndPoint remoteEndPoint, long size)
 {
     User = user;
     FileName = filename;
     DestinationFile = filename;
     DestinationDir = "";
     RemoteEndPoint = remoteEndPoint;
     Size = size;
     Accept = Dcc.AcceptTransfer;
     Timeout = TimeSpan.FromMinutes(1);
 }
        public PrivateMessage(IrcMessage message)
        {
            Source = message.Parameters[0];
            Message = message.Parameters[1];

            User = new IrcUser(message.Prefix);
            if (Source.StartsWith("#"))
                IsChannelMessage = true;
            else
                Source = User.Nick;
        }
Ejemplo n.º 45
0
 public DccReceiveClient(Dcc dcc, IrcUser user, Socket sock, IPEndPoint addr, FileInfo file, long totalSize,
                         TimeSpan timeout)
     : base(dcc, user, sock, file, 0, totalSize)
 {
     m_remoteAddr = addr;
     // m_sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 10000)
     m_timeoutTimer           = new Timer((int)timeout.TotalMilliseconds);
     m_timeoutTimer.Elapsed  += OnTimeout;
     m_timeoutTimer.AutoReset = false;
     m_timeoutTimer.Start();
 }
Ejemplo n.º 46
0
        public IrcClient(string serverAddress, IrcUser user)
        {
            if (serverAddress == null) throw new ArgumentNullException("serverAddress");
            if (user == null) throw new ArgumentNullException("user");

            User = user;
            ServerAddress = serverAddress;
            Encoding = Encoding.UTF8;
            Channels = new ChannelCollection(this);
            Settings = new ClientSettings();
        }
Ejemplo n.º 47
0
 public IrcQueryViewModel(IrcUser user, IrcClient client, Settings settings)
 {
     this.Settings    = settings;
     this.User        = user;
     this.client      = client;
     this.DisplayName = user.NickName;
     this.Messages    = new BindableCollection <Message>();
     this.Closable    = true;
     // TODO
     this.client.LocalUser.MessageReceived += this.messageReceived;
 }
Ejemplo n.º 48
0
        public PrivateMessage(IrcMessage message, ServerInfo serverInfo)
        {
            Source = message.Parameters[0];
            Message = message.Parameters[1];

            User = new IrcUser(message.Prefix);
            if (serverInfo.ChannelTypes.Any(c => Source.StartsWith(c.ToString())))
                IsChannelMessage = true;
            else
                Source = User.Nick;
        }
Ejemplo n.º 49
0
        // List of all currently logged-in Twitter users.
        // private List<CellAOUsers> cellAoUserses;

        private CellAoBotUser GetCellAOBotUser(IrcUser ircUSer)
        {
            CellAoBotUser CellAOUser = this.cellAoBotUsers.SingleOrDefault(tu => tu.IrcUser == ircUSer);

            if (CellAOUser == null)
            {
                throw new InvalidOperationException(
                          string.Format("User '{0}' is not logged in to Cellao.", ircUSer.NickName));
            }
            return(CellAOUser);
        }
Ejemplo n.º 50
0
        protected override string OnAuthPacketReceived(IrcUser user, IrcPacket packet)
        {
            packet.Content.SkipWord();

            var nick = packet.Content.NextWord();
            if (nick == user.Nick)
            {
                var userName = packet.Content.NextWord();
                return userName;
            }
            return null;
        }
        private void AddUserMessage(Message message, IrcUser user)
        {
            if (user == this.Network.CurrentUser)
            {
                this._networkInfoViewModel.AddMessage(message);
            }

            foreach (var vm in this.Conversations.Where(c => c.Users.Contains(user)))
            {
                vm.AddMessage(message);
            }
        }
Ejemplo n.º 52
0
        public void DisconnectUser(string nick)
        {
            // Example
            //:002G7Y912 QUIT :Quit: Leaving
            IrcUser user = GetIrcUser(nick);

            if (null != user)
            {
                Write($":{user.UID} QUIT :Quit: Discord User Left");
                IrcUsers.Remove(user);
            }
        }
Ejemplo n.º 53
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CtcpMessageEventArgs"/> class.
        /// </summary>
        /// <param name="source">The source of the message.</param>
        /// <param name="targets">A list of the targets of the message.</param>
        /// <param name="text">The text of the message.</param>
        /// <exception cref="ArgumentNullException"><paramref name="targets"/> is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="text"/> is <see langword="null"/>.</exception>
        public CtcpMessageEventArgs(IrcUser source, IList<IIrcMessageTarget> targets, string text)
            : base()
        {
            if (targets == null)
                throw new ArgumentNullException("target");
            if (text == null)
                throw new ArgumentNullException("text");

            this.Source = source;
            this.Targets = new ReadOnlyCollection<IIrcMessageTarget>(targets);
            this.Text = text;
        }
Ejemplo n.º 54
0
 public override void HandleCommand(IList<string> paramList, IrcUser user, bool isIngameCommand)
 {
     if (paramList.Count > 1)
     {
         var queryString = "http://www.google.com/search?q=";
         for (var i = 1; i < paramList.Count; i++)
         {
             queryString = queryString + (paramList[i] + "+");
         }
         Utils.SendChannel(queryString.Substring(0, queryString.Length - 1));
     }
 }
Ejemplo n.º 55
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Message"></param>
        protected override void HandleAdminMessage(AdminMessage Message)
        {
            base.HandleAdminMessage(Message);

            // no proper message text?
            if (Message.Message == null || String.Equals(Message.Message, String.Empty))
            {
                return;
            }

            // check if irc is available
            if (IrcChannel != null)
            {
                // IRC does not allow \r \n \0
                // so we remove \0 and remove \r\n by splitting up into lines
                string[] lines = Util.SplitLinebreaks(Message.Message.Replace("\0", String.Empty));

                // Only want to send to any admins who've sent a command since last GC.
                // Other admins don't need to know about GC.
                List <string> recipients;
                bool          clearRecent = false;
                if (Util.IsGarbageCollectMessage(lines[0]))
                {
                    recipients  = RecentAdmins;
                    clearRecent = true;
                }
                else
                {
                    recipients = Config.Admins;
                }

                // forward line by line
                foreach (string line in lines)
                {
                    // forward this line to each admin
                    foreach (string admin in recipients)
                    {
                        // try get channeluser by name
                        IrcUser usr = GetChannelUser(admin);

                        // online? send!
                        if (usr != null)
                        {
                            SendIRCMessage(admin, line);
                        }
                    }
                }
                if (clearRecent)
                {
                    RecentAdmins.Clear();
                }
            }
        }
Ejemplo n.º 56
0
        public Request(IrcClient connection, string channel, IrcUser sender, DateTime?time, TimeSpan?zone, TimeSpan?targetZone, string zoneName)
        {
            this.Connection = connection;
            this.Channel    = channel;
            this.Sender     = sender;
            this.Time       = time;
            this.Zone       = zone;
            this.TargetZone = targetZone;
            this.ZoneName   = zoneName;

            this.RequestTime = DateTime.Now;
        }
        private IrcConversationViewModel GetConversation(IrcUser user)
        {
            var vm = this.Conversations.FirstOrDefault(c => c.TargetName == user.Nickname);

            if (vm == null)
            {
                vm = new IrcUserViewModel(user, this);
                this.AddConversation(vm);
            }

            return(vm);
        }
Ejemplo n.º 58
0
 protected override void OnQuit(IrcUser user, string reason)
 {
     Console.ForegroundColor = ConsoleColor.Green;
     if (user == Me)
     {
         Console.WriteLine("({0}) <IRC Interface> * Bot quits ({1})", DateTime.Now.ToString("hh:mm"), reason);
     }
     else
     {
         Console.WriteLine("({0}) <IRC Interface> * {1} quits ({2})", DateTime.Now.ToString("hh:mm"), user.Nick, reason);
     }
 }
Ejemplo n.º 59
0
 public override void HandleCommand(IList<string> paramList, IrcUser user, bool isIngameCommand)
 {
     if (isIngameCommand == false)
     {
         var random = new Random();
         Utils.SendChannel(string.Format("{0} their hand into a giant top hat and produces {1}", Data.HatActions[random.Next(0, Data.HatActions.Count())], Data.HatItems[random.Next(0, Data.HatItems.Count())]));
     }
     else
     {
         Utils.SendChannel(Data.MessageRestrictedIrc);
     }
 }
Ejemplo n.º 60
0
        public void Update_Always_PropertiesChanged()
        {
            var client   = TestHelper.GetTestIrcClient();
            var user     = new IrcUser(client, "test_nick", "test_ident", "test_host");
            var hostMask = IrcHostMask.Parse("updated_test_nick!update_test_ident@updated_test_host");

            user.Update(hostMask);

            Assert.True(user.NickName == hostMask.NickName);
            Assert.True(user.Ident == hostMask.Ident);
            Assert.True(user.Host == hostMask.Host);
        }