コード例 #1
0
        public async Task Reply(TelegramBotClient client, Update hook, JobBotDbContext ctx = null)
        {
            var user = await ctx.Users.FirstOrDefaultAsync(x => x.ChatId == hook.ChatId());

            user.SearchEnabled = true;

            ctx.Users.Update(user);

            await ctx.SaveChangesAsync();
        }
コード例 #2
0
        public async Task Reply(TelegramBotClient client, Update hook, JobBotDbContext ctx = null)
        {
            var user = await ctx.Users.FirstOrDefaultAsync(x => x.ChatId == hook.ChatId());

            var preferences = hook.Message.Text.TrimStart(UpdatePreferencesCommand.ToCharArray()).Trim();

            user.Preferences = preferences;

            ctx.Users.Update(user);
            await ctx.SaveChangesAsync();

            await client.SendTextMessageAsync(hook.ChatId(), "preferences changed to " + preferences);
        }
コード例 #3
0
        public async Task EnsureRegistered(Update hook)
        {
            var userExist = _context.Users.FirstOrDefault(x => x.ChatId == hook.ChatId());

            if (userExist == null)
            {
                var user = new Data.Entities.User()
                {
                    ChatId        = hook.ChatId(),
                    SearchEnabled = true
                };
                _context.Users.Add(user);
                await _context.SaveChangesAsync();
            }
        }