Esempio n. 1
0
        static void Main(string[] args)
        {
            logger = new FileLogger(false);
            var settings = new Settings();

            settings.Read();

            if (Settings.DefaultToken == "")
            {
                logger.Log("ERROR: Token not set!", true);
                logger.Close();
                throw new Exception("ERROR: Token not set!");
            }

            var exit = new ExitWait();

            exit.Start();

            if (Settings.DefaultStartTele == "ON")
            {
                new PipeTeleServer();
            }
            if (Settings.DefaultStartEmail == "ON")
            {
                new PipeEmailServer();
            }
        }
Esempio n. 2
0
    public BotClient(string token, string chatid)
    {
        logger   = new FileLogger(false);
        settings = new Settings();

        chat_id = chatid.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
        try
        {
            telebotClient = new TelegramBotClient(token);
        }
        catch (System.ArgumentException e)
        {
            logger.Log(string.Format("TelegramBotClient ERROR: {0}", e.Message), true);
            logger.Close();
            throw new Exception("ERROR: Telegram Bot Client not init!");
        }

        var me = telebotClient.GetMeAsync().Result;

        logger.Log(string.Format("Hello! I am user {0} and my name is {1}.", me.Id, me.FirstName), true);
        if (chatid == "")
        {
            logger.Log("Chat ID not set yet", true);
        }

        telebotClient.OnMessage += Bot_OnMessage;
        telebotClient.StartReceiving();
    }
Esempio n. 3
0
        /// <summary>
        /// Main function that performs in backup
        /// </summary>
        void BackupThreadJob()
        {
            _log.ProcedureCall("BackupThreadJob");

            foreach (var task in _tasks)
            {
                _task = task;
                _log.WriteLine(LoggingEvent.Debug, "Processing backup task {0}", task.Name);
                Collection <MetaRecord> metarecords;
                ArchiveTask[]           archiveParameters;

                if (BeforeBackup(out metarecords, out archiveParameters))
                {
                    if (!_aborting)
                    {
                        RunProgramsChainBeforeBackup();
                    }
                    if (!_aborting)
                    {
                        Start(metarecords, archiveParameters);
                    }
                    if (!_aborting)
                    {
                        AfterBackup();
                    }
                }
            }

            _log.Close();

            // Alarming that all finished
            if (_onBackupFinished != null)
            {
                _onBackupFinished.Invoke();
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Initialize a log instance by specified configuration.
 /// </summary>
 /// <param name="logConfig">The specified log configuration.</param>
 public static void Initialize(LogConfig logConfig)
 {
     _logInstance?.Close();
     _logInstance = LogBase.CreateLogWriter(logConfig);
 }