ConfigExists() public static method

Returns true if this channel is already existing in memory
public static ConfigExists ( string _Channel ) : bool
_Channel string
return bool
Esempio n. 1
0
 /// <summary>
 /// Join channel
 /// </summary>
 public static void AddChannel(CommandParams parameters)
 {
     if (!String.IsNullOrEmpty(parameters.Parameters))
     {
         while (!IRC.FinishedJoining)
         {
             Syslog.Log("Postponing request to join " + parameters.Parameters + " because bot is still loading", true);
             Thread.Sleep(2000);
         }
         List <string> pm = new List <string>(parameters.Parameters.Trim().Split(' '));
         if (pm.Count > 2 || pm.Count == 0)
         {
             IRC.DeliverMessage("Invalid number of parameters, please provide up to 2 parameters (name, password)", parameters.SourceChannel);
             return;
         }
         string channel_name = pm[0];
         string password     = null;
         if (pm.Count > 1)
         {
             password = pm[1];
         }
         if (!Core.ValidFile(channel_name) || !channel_name.StartsWith("#"))
         {
             IRC.DeliverMessage(messages.Localize("InvalidName", parameters.SourceChannel.Language, new List <string> {
                 channel_name
             }), parameters.SourceChannel);
             return;
         }
         lock (Configuration.Channels)
         {
             foreach (Channel cu in Configuration.Channels)
             {
                 if (channel_name == cu.Name)
                 {
                     IRC.DeliverMessage(messages.Localize("ChannelIn", parameters.SourceChannel.Language), parameters.SourceChannel);
                     return;
                 }
             }
         }
         bool    existing = Channel.ConfigExists(channel_name);
         Channel channel  = new Channel(channel_name)
         {
             Password = password
         };
         lock (Configuration.Channels)
         {
             Configuration.Channels.Add(channel);
         }
         IRC.DeliverMessage("Attempting to join " + channel_name + " using " + channel.PrimaryInstance.Nick, parameters.SourceChannel.Name);
         Configuration.Save();
         Syslog.DebugLog("Sending join " + channel_name);
         channel.PrimaryInstance.Network.Join(channel_name, password);
         Channel Chan = Core.GetChannel(channel_name);
         if (!existing)
         {
             Chan.SystemUsers.AddUser("admin", Security.EscapeUser(parameters.User.Nick) + "!.*@" + Security.EscapeUser(parameters.User.Host));
         }
         if (Chan.Extension_GetConfig("generic.founder") == null)
         {
             Chan.Extension_SetConfig("generic.founder", parameters.User.ToString());
             Chan.Extension_SetConfig("generic.owner", parameters.User.ToString());
         }
         else
         {
             Chan.Extension_SetConfig("generic.owner", parameters.User.ToString());
         }
         Chan.Extension_SetConfig("generic.joindate", DateTime.Now.ToString());
         Chan.SaveConfig();
         return;
     }
     IRC.DeliverMessage(messages.Localize("InvalidName", parameters.SourceChannel.Language), parameters.SourceChannel);
     return;
 }