Ejemplo n.º 1
0
 public Gambling(IBotConfigProvider bc, IUnitOfWork uow, CurrencyService currency, DbService db)
 {
     _bc       = bc;
     this.uow  = uow;
     _currency = currency;
     _db       = db;
 }
Ejemplo n.º 2
0
 public WaifuClaimCommands(IDataCache cache, IBotConfigProvider bc, CurrencyService cs, DbService db)
 {
     _bc    = bc;
     _cs    = cs;
     _db    = db;
     _cache = cache;
 }
 public DailyMoneyCommands(IBotConfigProvider bc, IUnitOfWork uow, CurrencyService currency, GuildTimezoneService gts)
 {
     _bc       = bc;
     this.uow  = uow;
     _currency = currency;
     _gts      = gts;
 }
        public RemindService(DiscordSocketClient client,
                             IBotConfigProvider config,
                             DbService db,
                             StartingGuildsService guilds)
        {
            _config = config;
            _client = client;
            _log    = LogManager.GetCurrentClassLogger();
            _db     = db;

            cancelSource   = new CancellationTokenSource();
            cancelAllToken = cancelSource.Token;

            List <Reminder> reminders;

            using (var uow = _db.UnitOfWork)
            {
                reminders = uow.Reminders.GetIncludedReminders(guilds).ToList();
            }
            RemindMessageFormat = _config.BotConfig.RemindMessageFormat;

            foreach (var r in reminders)
            {
                Task.Run(() => StartReminder(r));
            }
        }
 public WheelOfFortuneCommands(CurrencyService cs, IBotConfigProvider bc,
                               DbService db)
 {
     _cs = cs;
     _bc = bc;
     _db = db;
 }
Ejemplo n.º 6
0
 public WaifuService(DbService db, ICurrencyService cs, IBotConfigProvider bc, IDataCache cache)
 {
     _db    = db;
     _cs    = cs;
     _bc    = bc;
     _cache = cache;
 }
Ejemplo n.º 7
0
        public PlantPickService(DbService db, CommandHandler cmd, NadekoBot bot, NadekoStrings strings,
                                IDataCache cache, FontProvider fonts, IBotConfigProvider bc, ICurrencyService cs,
                                CommandHandler cmdHandler, DiscordSocketClient client)
        {
            _db         = db;
            _strings    = strings;
            _images     = cache.LocalImages;
            _fonts      = fonts;
            _bc         = bc;
            _log        = LogManager.GetCurrentClassLogger();
            _cs         = cs;
            _cmdHandler = cmdHandler;
            _rng        = new NadekoRandom();
            _client     = client;

            cmd.OnMessageNoTrigger += PotentialFlowerGeneration;
            using (var uow = db.GetDbContext())
            {
                var guildIds = client.Guilds.Select(x => x.Id).ToList();
                var configs  = uow._context.Set <GuildConfig>()
                               .AsQueryable()
                               .Include(x => x.GenerateCurrencyChannelIds)
                               .Where(x => guildIds.Contains(x.GuildId))
                               .ToList();

                _generationChannels = new ConcurrentHashSet <ulong>(configs
                                                                    .SelectMany(c => c.GenerateCurrencyChannelIds.Select(obj => obj.ChannelId)));
            }
        }
Ejemplo n.º 8
0
        public GamesService(CommandHandler cmd, IBotConfigProvider bc, NadekoBot bot,
                            NadekoStrings strings, IDataCache data, CommandHandler cmdHandler,
                            ICurrencyService cs, FontProvider fonts)
        {
            _bc         = bc;
            _cmd        = cmd;
            _strings    = strings;
            _images     = data.LocalImages;
            _cmdHandler = cmdHandler;
            _log        = LogManager.GetCurrentClassLogger();
            _rng        = new NadekoRandom();
            _cs         = cs;
            _fonts      = fonts;

            //8ball
            EightBallResponses = _bc.BotConfig.EightBallResponses.Select(ebr => ebr.Text).ToImmutableArray();

            //girl ratings
            _t = new Timer((_) =>
            {
                GirlRatings.Clear();
            }, null, TimeSpan.FromDays(1), TimeSpan.FromDays(1));

            try
            {
                TypingArticles = JsonConvert.DeserializeObject <List <TypingArticle> >(File.ReadAllText(TypingArticlesPath));
            }
            catch (Exception ex)
            {
                _log.Warn("Error while loading typing articles {0}", ex.ToString());
                TypingArticles = new List <TypingArticle>();
            }
        }
Ejemplo n.º 9
0
 public SelfCommands(IUnitOfWork uow, DiscordSocketClient client, IImagesService images, IBotConfigProvider bc)
 {
     this.uow = uow;
     _client  = client;
     _images  = images;
     _bc      = bc;
 }
Ejemplo n.º 10
0
 public HelpService(IBotConfigProvider bc, CommandHandler ch, NadekoStrings strings)
 {
     _bc      = bc;
     _ch      = ch;
     _strings = strings;
     _log     = LogManager.GetCurrentClassLogger();
 }
Ejemplo n.º 11
0
        public CommandHandler(DiscordSocketClient client, DbService db,
                              IBotConfigProvider bcp, CommandService commandService,
                              IBotCredentials credentials, NadekoBot bot, IServiceProvider services)
        {
            _client         = client;
            _commandService = commandService;
            _creds          = credentials;
            _bot            = bot;
            _db             = db;
            _bcp            = bcp;
            _services       = services;

            _log = LogManager.GetCurrentClassLogger();

            _clearUsersOnShortCooldown = new Timer(_ =>
            {
                UsersOnShortCooldown.Clear();
            }, null, GlobalCommandsCooldown, GlobalCommandsCooldown);

            DefaultPrefix = bcp.BotConfig.DefaultPrefix;
            _prefixes     = bot.AllGuildConfigs
                            .Where(x => x.Prefix != null)
                            .ToDictionary(x => x.GuildId, x => x.Prefix)
                            .ToConcurrent();
        }
        public GamesService(CommandHandler cmd, IBotConfigProvider bc, IEnumerable <GuildConfig> gcs,
                            NadekoStrings strings, IImagesService images, CommandHandler cmdHandler)
        {
            _bc         = bc;
            _cmd        = cmd;
            _strings    = strings;
            _images     = images;
            _cmdHandler = cmdHandler;
            _log        = LogManager.GetCurrentClassLogger();

            //8ball
            EightBallResponses = _bc.BotConfig.EightBallResponses.Select(ebr => ebr.Text).ToImmutableArray();

            //girl ratings
            _t = new Timer((_) =>
            {
                GirlRatings.Clear();
            }, null, TimeSpan.FromDays(1), TimeSpan.FromDays(1));

            //plantpick
            _cmd.OnMessageNoTrigger += PotentialFlowerGeneration;
            GenerationChannels       = new ConcurrentHashSet <ulong>(gcs
                                                                     .SelectMany(c => c.GenerateCurrencyChannelIds.Select(obj => obj.ChannelId)));

            try
            {
                TypingArticles = JsonConvert.DeserializeObject <List <TypingArticle> >(File.ReadAllText(TypingArticlesPath));
            }
            catch (Exception ex)
            {
                _log.Warn("Error while loading typing articles {0}", ex.ToString());
                TypingArticles = new List <TypingArticle>();
            }
        }
Ejemplo n.º 13
0
 public PlantPickCommands(IBotConfigProvider bc, CurrencyService cs,
                          DbService db)
 {
     _bc = bc;
     _cs = cs;
     _db = db;
 }
Ejemplo n.º 14
0
        public PatreonRewardsService(IBotCredentials creds, DbService db,
                                     CurrencyService currency,
                                     DiscordSocketClient client, IDataCache cache, IBotConfigProvider bc)
        {
            _log      = LogManager.GetCurrentClassLogger();
            _creds    = creds;
            _db       = db;
            _currency = currency;
            _cache    = cache;
            _key      = _creds.RedisKey() + "_patreon_rewards";
            _bc       = bc;

            _pledges = new FactoryCache <PatreonUserAndReward[]>(() =>
            {
                var r    = _cache.Redis.GetDatabase();
                var data = r.StringGet(_key);
                if (data.IsNullOrEmpty)
                {
                    return(null);
                }
                else
                {
                    return(JsonConvert.DeserializeObject <PatreonUserAndReward[]>(data));
                }
            }, TimeSpan.FromSeconds(20));

            if (client.ShardId == 0)
            {
                Updater = new Timer(async _ => await RefreshPledges(),
                                    null, TimeSpan.Zero, Interval);
            }
        }
Ejemplo n.º 15
0
 public Help(IBotCredentials creds, GlobalPermissionService perms, IBotConfigProvider config, CommandService cmds)
 {
     _creds  = creds;
     _config = config;
     _cmds   = cmds;
     _perms  = perms;
 }
Ejemplo n.º 16
0
 public FlowerShopCommands(IBotConfigProvider bc, DbService db, CurrencyService cs, DiscordSocketClient client)
 {
     _db     = db;
     _bc     = bc;
     _cs     = cs;
     _client = client;
 }
Ejemplo n.º 17
0
 public PatreonCommands(IBotCredentials creds, IBotConfigProvider config, DbService db, CurrencyService currency)
 {
     _creds    = creds;
     _config   = config;
     _db       = db;
     _currency = currency;
 }
Ejemplo n.º 18
0
 public UserPunishCommands(DbService db, MuteService muteService,
                           CurrencyService cs, IBotConfigProvider bc)
 {
     _db = db;
     _cs = cs;
     _bc = bc;
 }
Ejemplo n.º 19
0
        public GameStatusEvent(DiscordSocketClient client, ICurrencyService cs,
                               IBotConfigProvider bc, SocketGuild g, ITextChannel ch,
                               EventOptions opt,
                               Func <CurrencyEvent.Type, EventOptions, long, EmbedBuilder> embedFunc)
        {
            _log          = LogManager.GetCurrentClassLogger();
            _client       = client;
            _guild        = g;
            _cs           = cs;
            _amount       = opt.Amount;
            PotSize       = opt.PotSize;
            _embedFunc    = embedFunc;
            _isPotLimited = PotSize > 0;
            _channel      = ch;
            _bc           = bc;
            _opts         = opt;
            // generate code
            _code = new string(_sneakyGameStatusChars.Shuffle().Take(5).ToArray());

            _t = new Timer(OnTimerTick, null, Timeout.InfiniteTimeSpan, TimeSpan.FromSeconds(2));
            if (_opts.Hours > 0)
            {
                _timeout = new Timer(EventTimeout, null, TimeSpan.FromHours(_opts.Hours), Timeout.InfiniteTimeSpan);
            }
        }
Ejemplo n.º 20
0
        public BlacklistService(IBotConfigProvider bc)
        {
            var blacklist = bc.BotConfig.Blacklist;

            BlacklistedUsers    = new ConcurrentHashSet <ulong>(blacklist.Where(bi => bi.Type == BlacklistType.User).Select(c => c.ItemId));
            BlacklistedGuilds   = new ConcurrentHashSet <ulong>(blacklist.Where(bi => bi.Type == BlacklistType.Server).Select(c => c.ItemId));
            BlacklistedChannels = new ConcurrentHashSet <ulong>(blacklist.Where(bi => bi.Type == BlacklistType.Channel).Select(c => c.ItemId));
        }
 public CurrencyEventsService(DbService db, DiscordSocketClient client, ICurrencyService cs, IBotConfigProvider bc)
 {
     _db     = db;
     _client = client;
     _cs     = cs;
     _bc     = bc;
     _log    = LogManager.GetCurrentClassLogger();
 }
Ejemplo n.º 22
0
        public GamesService(IBotConfigProvider bcp)
        {
            _bcp = bcp;

            var timer = new Timer(_ => {
                GirlRatings.Clear();
            }, null, TimeSpan.FromDays(1), TimeSpan.FromDays(1));
        }
Ejemplo n.º 23
0
 public SneakyEvent(ICurrencyService cs, DiscordSocketClient client,
                    IBotConfigProvider bc, long len)
 {
     _cs     = cs;
     _client = client;
     _bc     = bc;
     _length = len;
 }
Ejemplo n.º 24
0
 public Gambling(IBotConfigProvider bc, DbService db, CurrencyService currency,
                 IDataCache cache)
 {
     _bc    = bc;
     _db    = db;
     _cs    = currency;
     _cache = cache;
 }
Ejemplo n.º 25
0
 public WaifuService(DbService db, ICurrencyService cs, IBotConfigProvider bc, IDataCache cache)
 {
     _db    = db;
     _cs    = cs;
     _bc    = bc;
     _cache = cache;
     _log   = LogManager.GetCurrentClassLogger();
 }
Ejemplo n.º 26
0
 public FlipCoinCommands(IDataCache data, CurrencyService cs,
                         IBotConfigProvider bc, DbService db)
 {
     _images = data.LocalImages;
     _bc     = bc;
     _cs     = cs;
     _db     = db;
 }
Ejemplo n.º 27
0
 public TriviaCommands(DiscordSocketClient client, IDataCache cache,
                       IBotConfigProvider bc, CurrencyService cs)
 {
     _cache  = cache;
     _cs     = cs;
     _client = client;
     _bc     = bc;
 }
Ejemplo n.º 28
0
 public FlowerShopCommands(DbService db, ICurrencyService cs, DiscordSocketClient client, IBotConfigProvider bc)//, ILeaderboardRepository lb, IRoleInventoryRepository ri)
 {
     _db     = db;
     _cs     = cs;
     _client = client;
     _bc     = bc;
     _lb     = db.GetDbContext().Leaderboards;
     _ri     = db.GetDbContext().RoleInventory;
 }
Ejemplo n.º 29
0
 public Gambling(IBotConfigProvider bc, DbService db, CurrencyService currency,
                 IDataCache cache, DiscordSocketClient client)
 {
     _bc     = bc;
     _db     = db;
     _cs     = currency;
     _cache  = cache;
     _client = client;
 }
Ejemplo n.º 30
0
 public SelfCommands(DbService db, DiscordSocketClient client,
                     MusicService music, IImagesService images, IBotConfigProvider bc)
 {
     _db     = db;
     _client = client;
     _images = images;
     _music  = music;
     _bc     = bc;
 }