private bool SQLOnline() { BusinessLogic.SysConfigLogic sysConfigLogic = new BusinessLogic.SysConfigLogic(); var conf = sysConfigLogic.GetById("motd"); return(conf != null ? true : false); }
private static void InitializeAll() { // Initialize database context using (Data.UBContext ubc = new Data.UBContext( CacheData.Configuration["Database"])) { } BusinessLogic.SysConfigLogic sysConfigLogic = new BusinessLogic.SysConfigLogic(); CacheData.SysConfigs = new List <Models.SysConfig>(sysConfigLogic.Get()); BusinessLogic.OperatorLogic operatorLogic = new BusinessLogic.OperatorLogic(); CacheData.Operators = new List <Models.Operator>(operatorLogic.Get()); Bot.Manager.Initialize(CacheData.Configuration["APIKEY"]); LoadCacheData(); InitializeHangfireServer(); Controls.Manager.Initialize(); Bot.MessageQueueManager.Initialize(); Bot.CommandQueueManager.Initialize(); Utils.LogTools.Initialize(); Utils.ConfigTools.Initialize(); Utils.ChatTools.Initialize(); Utils.UserTools.Initialize(); Bot.Manager.StartReceiving(); #if DEBUG TestArea.DoTest(); #endif Data.Utils.Logging.AddLog(new Models.SystemLog() { LoggerName = CacheData.LoggerName, Date = DateTime.Now, Function = "Unifiedban Terminal Startup", Level = Models.SystemLog.Levels.Info, Message = "Startup completed", UserId = -2 }); }
public void Execute(Message message) { if (CacheData.Operators .SingleOrDefault(x => x.TelegramUserId == message.From.Id && x.Level == Models.Operator.Levels.Super) == null) { MessageQueueManager.EnqueueMessage( new Models.ChatMessage() { Timestamp = DateTime.UtcNow, Chat = message.Chat, ReplyToMessageId = message.MessageId, Text = CacheData.GetTranslation("en", "error_not_auth_command") }); Manager.BotClient.SendTextMessageAsync( chatId: CacheData.ControlChatId, parseMode: ParseMode.Markdown, text: String.Format( "*[Report]*\n" + "⚠️ Non operator tried to use /reload\n" + "\n*Chat:* {0}" + "\n*ChatId:* {1}" + "\n*UserId:* {2}" + "\n\n*hash_code:* #UB{3}-{4}", message.Chat.Title, message.Chat.Id, message.From.Id, message.Chat.Id.ToString().Replace("-", ""), Guid.NewGuid()) ); return; } try { BusinessLogic.SysConfigLogic sysConfigLogic = new BusinessLogic.SysConfigLogic(); CacheData.SysConfigs = new List <Models.SysConfig>(sysConfigLogic.Get()); Data.Utils.Logging.AddLog(new Models.SystemLog() { LoggerName = CacheData.LoggerName, Date = DateTime.Now, Function = "Unifiedban.Terminal.Command.ReloadConf", Level = Models.SystemLog.Levels.Info, Message = "Conf reloaded successfully.", UserId = -1 }); Manager.BotClient.SendTextMessageAsync( chatId: message.Chat.Id, text: "Conf reloaded successfully." ); } catch (Exception ex) { Data.Utils.Logging.AddLog(new Models.SystemLog() { LoggerName = CacheData.LoggerName, Date = DateTime.Now, Function = "Unifiedban.Terminal.Command.ReloadConf", Level = Models.SystemLog.Levels.Error, Message = ex.Message, UserId = -1 }); Manager.BotClient.SendTextMessageAsync( chatId: message.Chat.Id, text: "Error reloading conf. Check logs." ); } }