ContainsUser() 공개 메소드

Return true if user is present in channel
public ContainsUser ( string name ) : bool
name string
리턴 bool
예제 #1
0
 public void RetrieveStatus2(string nick, Channel channel, string source)
 {
     try
     {
         string response = "I have never seen " + nick;
         bool found = false;
         string action = "quiting the network";
         lock (GlobalList)
         {
             foreach (item xx in GlobalList)
             {
                 if (nick.ToUpper() == xx.nick.ToUpper())
                 {
                     found = true;
                     Channel last;
                     switch (xx.LastAc)
                     {
                         case item.Action.Join:
                             action = "joining the channel";
                             last = Core.GetChannel(xx.lastplace);
                             if (last != null)
                             {
                                 if (last.ContainsUser(nick))
                                 {
                                     action += ", they are still in the channel";
                                 }
                                 else
                                 {
                                     action += ", but they are not in the channel now and I don't know why, in";
                                 }
                             }
                             break;
                         case item.Action.Kick:
                             action = "kicked from the channel";
                             break;
                         case item.Action.Nick:
                             if (xx.newnick == null)
                             {
                                 action = "error NULL pointer at record";
                                 break;
                             }
                             action = "changing the nickname to " + xx.newnick;
                             last = Core.GetChannel(xx.lastplace);
                             if (last.ContainsUser(xx.newnick))
                             {
                                 action += " and " + xx.newnick + " is still in the channel";
                             }
                             else
                             {
                                 action += ", but " + xx.newnick + " is no longer in channel";
                             }
                             item nick2 = getItem(xx.newnick);
                             if (nick2 != null)
                             {
                                 TimeSpan span3 = DateTime.Now - nick2.LastSeen;
                                 switch (nick2.LastAc)
                                 {
                                     case item.Action.Exit:
                                         action += " because he quitted the network " + span3.ToString() + " ago. The nick change was done in";
                                         break;
                                     case item.Action.Kick:
                                         action += " because he was kicked from the channel " + span3.ToString() + " ago. The nick change was done in";
                                         break;
                                     case item.Action.Part:
                                         action += " because he left the channel " + span3.ToString() + " ago. The nick change was done in";
                                         break;
                                 }
                             }
                             break;
                         case item.Action.Part:
                             action = "leaving the channel";
                             break;
                         case item.Action.Talk:
                             action = "talking in the channel";
                             last = Core.GetChannel(xx.lastplace);
                             if (last != null)
                             {
                                 if (last.ContainsUser(nick))
                                 {
                                     action += ", they are still in the channel";
                                 }
                                 else
                                 {
                                     action += ", but they are not in the channel now and I don't know why, in";
                                 }
                             }
                             break;
                         case item.Action.Exit:
                             string reason = xx.quit;
                             if (reason == "")
                             {
                                 reason = "no reason was given";
                             }
                             action = "quitting the network with reason: " + reason;
                             break;
                     }
                     TimeSpan span = DateTime.Now - xx.LastSeen;
                     if (xx.LastAc == item.Action.Exit)
                     {
                         response = "Last time I saw " + nick + " they were " + action + " at " + xx.LastSeen.ToString() + " (" + RegularModule.FormatTimeSpan (span) + " ago)";
                     }
                     response = "Last time I saw " + nick + " they were " + action + " " + xx.lastplace + " at " + xx.LastSeen.ToString() + " (" + RegularModule.FormatTimeSpan (span) + " ago)";
                     break;
                 }
             }
         }
         string target = source;
         if (channel != null)
         {
             target = channel.Name;
         }
         if (nick.ToUpper() == source.ToUpper())
         {
             response = "are you really looking for yourself?";
             Core.irc.Queue.DeliverMessage(source + ": " + response, target, IRC.priority.normal);
             return;
         }
         if (nick.ToUpper() == Configuration.IRC.NickName.ToUpper())
         {
             response = "I am right here";
             Core.irc.Queue.DeliverMessage(source + ": " + response, target, IRC.priority.normal);
             return;
         }
         if (channel != null)
         {
             if (channel.ContainsUser(nick))
             {
                 response = nick + " is in here, right now";
                 found = true;
             }
         }
         if (!found)
         {
             foreach (Channel Item in Configuration.ChannelList)
             {
                 if (Item.ContainsUser(nick))
                 {
                     response = nick + " is in " + Item.Name + " right now";
                     break;
                 }
             }
         }
         Core.irc.Queue.DeliverMessage(source + ": " + response, target, IRC.priority.normal);
     }
     catch (Exception fail)
     {
         HandleException(fail);
     }
 }