public SBController(SegasBotContext context) { _context = context; //if (_context.SBCommands.Count() == 0) //{ // _context.SBCommands.Add(new SBCommands { Answers = "Item1" }); // _context.SaveChanges(); //} }
public void BotInit(SegasBotContext context) { //var me = Bot.GetMeAsync().Result; if (!botIsRunning) { botIsRunning = true; _context = context; Bot.OnMessage += BotOnMessageReceived; Bot.OnMessageEdited += BotOnMessageReceived; Bot.OnCallbackQuery += BotOnCallbackQueryReceived; Bot.OnReceiveError += BotOnReceiveError; Bot.StartReceiving(Array.Empty <UpdateType>()); //reactionChance = 0; //BotReaction = false; ReactionSimulator = new ReactionSimulator(DataReader, Bot); } }
private static void SimpleDBInit(SegasBotContext ctx, IServiceProvider services) { try { var testItem = new SBCommands() { Answers = "1" }; ctx.SBCommands.Add(testItem); ctx.SaveChanges(); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while seeding the database."); } }
public static void Main(string[] args) { var host = CreateWebHostBuilder(args) .UseKestrel() .UseUrls("http://*:5000") .UseContentRoot(System.IO.Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup <Startup>() .Build(); var scope = host.Services.CreateScope(); var services = scope.ServiceProvider; SegasBotContext ctx = services.GetRequiredService <SegasBotContext>(); //Uncomment it when you need to init NEW DB //SimpleDBInit(ctx, services); InitBot(BotHome.GetBotHomeInstance, ctx); CreateWebHostBuilder(args).Build().Run(); StopBot(BotHome.GetBotHomeInstance); }
public void ReInitDataReader(SegasBotContext context) { DataReader.ReInit(context); }
public void ReInit(SegasBotContext context) { _context = context; Init(); }
public DataReader(SegasBotContext context) { _context = context; Init(); }
private static void InitBot(BotHome botHome, SegasBotContext context) { botHome.BotInit(context); }