Esempio n. 1
0
		public void Setup(string ServerName, bool LoadConfig = false)
		{
			_servername = ServerName;

			if(CleanConfig.Database)
			{
				Log.Debug("ExtraAddon", sLConsole.GetString("The deleting of messages that older than 30 days have been started."));

				var db = SchumixBase.DManager.Query("SELECT Id, UnixTime FROM message WHERE ServerName = '{0}'", ServerName);
				if(!db.IsNull())
				{
					foreach(DataRow row in db.Rows)
					{
						int time = row["UnixTime"].ToInt32();

						if((DateTime.Now - sUtilities.GetDateTimeFromUnixTime(time)).TotalDays > 30)
							SchumixBase.DManager.Delete("message", string.Format("Id = '{0}'", row["Id"].ToString()));
					}
				}

				Log.Debug("ExtraAddon", sLConsole.GetString("Message deletion has been ended."));
			}

			SchumixBase.DManager.Update("hlmessage", string.Format("ServerName = '{0}'", ServerName), string.Format("ServerId = '{0}'", IRCConfig.List[ServerName].ServerId));
			SchumixBase.DManager.Update("kicklist", string.Format("ServerName = '{0}'", ServerName), string.Format("ServerId = '{0}'", IRCConfig.List[ServerName].ServerId));
			SchumixBase.DManager.Update("modelist", string.Format("ServerName = '{0}'", ServerName), string.Format("ServerId = '{0}'", IRCConfig.List[ServerName].ServerId));
			SchumixBase.DManager.Update("message", string.Format("ServerName = '{0}'", ServerName), string.Format("ServerId = '{0}'", IRCConfig.List[ServerName].ServerId));
			SchumixBase.DManager.Update("notes", string.Format("ServerName = '{0}'", ServerName), string.Format("ServerId = '{0}'", IRCConfig.List[ServerName].ServerId));
			SchumixBase.DManager.Update("notes_users", string.Format("ServerName = '{0}'", ServerName), string.Format("ServerId = '{0}'", IRCConfig.List[ServerName].ServerId));

			if(CleanConfig.Database)
			{
				SchumixBase.sCleanManager.CDatabase.CleanTable("hlmessage");
				SchumixBase.sCleanManager.CDatabase.CleanTable("kicklist");
				SchumixBase.sCleanManager.CDatabase.CleanTable("modelist");
				SchumixBase.sCleanManager.CDatabase.CleanTable("message");
				SchumixBase.sCleanManager.CDatabase.CleanTable("notes");
				SchumixBase.sCleanManager.CDatabase.CleanTable("notes_users");
			}

			// Online
			sFunctions = new Functions(ServerName);
			sFunctions._timeronline.Interval = 10*60*1000;
			sFunctions._timeronline.Elapsed += sFunctions.HandleIsOnline;
			sFunctions._timeronline.Enabled = true;
			sFunctions._timeronline.Start();

			sIrcHandler = new IrcHandler(ServerName, sFunctions);
			sNotes = new Notes(ServerName, sIrcHandler.sNameList);

			sFunctions.IsOnline = false;
			sIrcHandler.sNameList.RandomAllVhost();

			if(IRCConfig.List[_servername].ServerId == 1 || LoadConfig)
				_config = new AddonConfig(Name, ".yml");

			sIrcBase.Networks[ServerName].IrcRegisterHandler("PRIVMSG",                HandlePrivmsg);
			sIrcBase.Networks[ServerName].IrcRegisterHandler("NOTICE",                 HandleNotice);
			sIrcBase.Networks[ServerName].IrcRegisterHandler("JOIN",                   sIrcHandler.HandleJoin);
			sIrcBase.Networks[ServerName].IrcRegisterHandler("PART",                   sIrcHandler.HandleLeft);
			sIrcBase.Networks[ServerName].IrcRegisterHandler("KICK",                   sIrcHandler.HandleKick);
			sIrcBase.Networks[ServerName].IrcRegisterHandler("QUIT",                   sIrcHandler.HandleQuit);
			sIrcBase.Networks[ServerName].IrcRegisterHandler("NICK",                   sIrcHandler.HandleNewNick);
			sIrcBase.Networks[ServerName].IrcRegisterHandler(ReplyCode.RPL_NAMREPLY,   sIrcHandler.HandleNameList);
			sIrcBase.Networks[ServerName].IrcRegisterHandler(ReplyCode.RPL_ENDOFNAMES, sIrcHandler.HandleEndNameList);
			sIrcBase.Networks[ServerName].IrcRegisterHandler(ReplyCode.RPL_WELCOME,    sIrcHandler.HandleSuccessfulAuth);
			InitIrcCommand();
		}
Esempio n. 2
0
		public int Reload(string RName, bool LoadConfig, string SName = "")
		{
			try
			{
				switch(RName.ToLower())
				{
					case "config":
						if(IRCConfig.List[_servername].ServerId == 1 || LoadConfig)
							_config = new AddonConfig(Name, ".yml");
						return 1;
					case "command":
						InitIrcCommand();
						RemoveIrcCommand();
						return 1;
				}
			}
			catch(Exception e)
			{
				Log.Error("ExtraAddon", sLConsole.GetString("Reload: ") + sLConsole.GetString("Failure details: {0}"), e.Message);
				return 0;
			}

			return -1;
		}