コード例 #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);
 }