示例#1
0
        public override bool Hook_OnUnload()
        {
            bool success = true;

            if (writer != null)
            {
                writer.thread.Abort();
                writer = null;
            }
            lock (Configuration.Channels)
            {
                foreach (Channel channel in Configuration.Channels)
                {
                    if (!channel.UnregisterObject("Infobot"))
                    {
                        success = false;
                    }
                }
            }
            if (!success)
            {
                Syslog.Log("Failed to unregister infobot objects in some channels", true);
            }
            return(success);
        }
示例#2
0
        public override bool Hook_OnRegister()
        {
            bool success = true;

            DebugLog("Registering channels");
            try
            {
                if (!Directory.Exists(SnapshotsDirectory))
                {
                    Syslog.Log("Creating snapshot directory for infobot");
                    Directory.CreateDirectory(SnapshotsDirectory);
                }
            }
            catch (Exception fail)
            {
                Snapshots = false;
                Core.HandleException(fail, "infobot");
            }
            writer = new InfobotWriter();
            writer.Init();
            lock (Configuration.Channels)
            {
                foreach (Channel channel in Configuration.Channels)
                {
                    Channel curr = channel;
                    bool    cs   = GetConfig(curr, "Infobot.Case", true);
                    if (!channel.RegisterObject(new Infobot(getDB(ref curr), channel, this, cs), "Infobot"))
                    {
                        success = false;
                    }
                    if (Snapshots)
                    {
                        try
                        {
                            if (Directory.Exists(SnapshotsDirectory + Path.DirectorySeparatorChar + channel.Name) == false)
                            {
                                Syslog.Log("Creating directory for infobot for " + channel.Name);
                                Directory.CreateDirectory(SnapshotsDirectory + Path.DirectorySeparatorChar + channel.Name);
                            }
                        }
                        catch (Exception fail)
                        {
                            Core.HandleException(fail, "infobot");
                        }
                    }
                }
            }
            RegisterCommand(new GenericCommand("infobot-keys", this.list_keys));
            if (!success)
            {
                Syslog.Log("Failed to register infobot objects in some channels", true);
            }
            return(success);
        }
示例#3
0
 public override bool Hook_OnUnload()
 {
     bool success = true;
     if (writer != null)
     {
         writer.thread.Abort();
         writer = null;
     }
     lock (Configuration.Channels)
     {
         foreach (Channel channel in Configuration.Channels)
         {
             if (!channel.UnregisterObject("Infobot"))
             {
                 success = false;
             }
         }
     }
     if (!success)
     {
         Syslog.Log("Failed to unregister infobot objects in some channels", true);
     }
     return success;
 }
示例#4
0
 public override bool Hook_OnRegister()
 {
     bool success = true;
     DebugLog("Registering channels");
     try
     {
         if (!Directory.Exists(SnapshotsDirectory))
         {
             Syslog.Log("Creating snapshot directory for infobot");
             Directory.CreateDirectory(SnapshotsDirectory);
         }
     }
     catch (Exception fail)
     {
         Snapshots = false;
         Core.HandleException(fail, "infobot");
     }
     writer = new InfobotWriter();
     writer.Init();
     lock (Configuration.Channels)
     {
         foreach (Channel channel in Configuration.Channels)
         {
             Channel curr = channel;
             bool cs = GetConfig(curr, "Infobot.Case", true);
             if (!channel.RegisterObject(new Infobot(getDB(ref curr), channel, this, cs), "Infobot"))
             {
                 success = false;
             }
             if (Snapshots)
             {
                 try
                 {
                     if (Directory.Exists(SnapshotsDirectory + Path.DirectorySeparatorChar + channel.Name) == false)
                     {
                         Syslog.Log("Creating directory for infobot for " + channel.Name);
                         Directory.CreateDirectory(SnapshotsDirectory + Path.DirectorySeparatorChar + channel.Name);
                     }
                 }
                 catch (Exception fail)
                 {
                     Core.HandleException(fail, "infobot");
                 }
             }
         }
     }
     if (!success)
     {
         Syslog.Log("Failed to register infobot objects in some channels", true);
     }
     return success;
 }