예제 #1
0
        public SBController(SegasBotContext context)
        {
            _context = context;

            //if (_context.SBCommands.Count() == 0)
            //{
            //    _context.SBCommands.Add(new SBCommands { Answers = "Item1" });
            //    _context.SaveChanges();
            //}
        }
예제 #2
0
 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);
     }
 }
예제 #3
0
 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.");
     }
 }
예제 #4
0
        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);
        }
예제 #5
0
 public void ReInitDataReader(SegasBotContext context)
 {
     DataReader.ReInit(context);
 }
예제 #6
0
 public void ReInit(SegasBotContext context)
 {
     _context = context;
     Init();
 }
예제 #7
0
 public DataReader(SegasBotContext context)
 {
     _context = context;
     Init();
 }
예제 #8
0
 private static void InitBot(BotHome botHome, SegasBotContext context)
 {
     botHome.BotInit(context);
 }