Exemplo n.º 1
0
        private async Task OnUpdateGuilds(IDiscordGuild g)
        {
            Framework.Bot bot = Framework.Bot.Instance;

            //DiscordSocketClient client = bot.Client.GetShardFor(g);
            //await countLib.PostStats(client.ShardId, client.Guilds.Count);
        }
Exemplo n.º 2
0
        public AccountManager(Framework.Bot bot)
        {
            OnGlobalLevelUp += (a, e, l) =>
            {
                DogStatsd.Counter("levels.global", l);
                return(Task.CompletedTask);
            };
            OnLocalLevelUp += async(a, e, l) =>
            {
                DogStatsd.Counter("levels.local", l);

                long guildId = (e as IDiscordGuildChannel).GuildId.ToDbLong();

                List <LevelRole> rolesObtained = new List <LevelRole>();

                using (var context = new MikiContext())
                {
                    rolesObtained = await context.LevelRoles
                                    .Where(p => p.GuildId == guildId && p.RequiredLevel == l && p.Automatic)
                                    .ToListAsync();

                    // await (a as IDiscordGuildUser).AddRolesAsync(rolesObtained.Select(x => x.Role).ToArray());

                    var setting = (LevelNotificationsSetting)await Setting.GetAsync(context, e.Id, DatabaseSettingId.LEVEL_NOTIFICATIONS);

                    if (setting == LevelNotificationsSetting.NONE)
                    {
                        return;
                    }

                    if (setting == LevelNotificationsSetting.REWARDS_ONLY && rolesObtained.Count == 0)
                    {
                        return;
                    }

                    LocaleInstance instance = await Locale.GetLanguageInstanceAsync(e.Id);

                    EmbedBuilder embed = new EmbedBuilder()
                    {
                        Title       = instance.GetString("miki_accounts_level_up_header"),
                        Description = instance.GetString("miki_accounts_level_up_content", $"{a.Username}#{a.Discriminator}", l),
                        Color       = new Color(1, 0.7f, 0.2f)
                    };

                    if (rolesObtained.Count > 0)
                    {
                        embed.AddInlineField("Rewards", string.Join("\n", rolesObtained.Select(x => $"New Role: **{x.GetRoleAsync().Result.Name}**")));
                    }

                    embed.ToEmbed().QueueToChannel(e);
                }
            };

            //	bot.Client.GuildUpdated += Client_GuildUpdated;
            //bot.Client.JoinedGuild   += Client_UserJoined;
            //bot.Client.LeftGuild  += Client_UserLeft;
            bot.Client.MessageCreate += CheckAsync;
        }
Exemplo n.º 3
0
        public AchievementManager(Framework.Bot bot)
        {
            this.bot = bot;

            AccountManager.Instance.OnGlobalLevelUp += async(u, c, l) =>
            {
                if (await provider.IsEnabled(Global.RedisClient, c.Id))
                {
                    LevelPacket p = new LevelPacket()
                    {
                        discordUser    = await(c as IDiscordGuildChannel).GetUserAsync(u.Id),
                        discordChannel = c,
                        level          = l,
                    };
                    await OnLevelGained?.Invoke(p);
                }
            };

            AccountManager.Instance.OnTransactionMade += async(msg, u1, u2, amount) =>
            {
                if (await provider.IsEnabled(Global.RedisClient, msg.ChannelId))
                {
                    TransactionPacket p = new TransactionPacket()
                    {
                        discordUser    = msg.Author,
                        discordChannel = await msg.GetChannelAsync(),
                        giver          = u1,
                        receiver       = u2,
                        amount         = amount
                    };

                    await OnTransaction?.Invoke(p);
                }
            };

            bot.GetAttachedObject <EventSystem>().GetCommandHandler <SimpleCommandHandler>().OnMessageProcessed += async(e, m, t) =>
            {
                CommandPacket p = new CommandPacket()
                {
                    discordUser    = m.Author,
                    discordChannel = await m.GetChannelAsync(),
                    message        = m,
                    command        = e,
                    success        = true
                };
                await OnCommandUsed?.Invoke(p);
            };
        }
Exemplo n.º 4
0
        public GeneralModule(Module m, Framework.Bot b)
        {
            //EventSystem.Instance.AddCommandDoneEvent(x =>
            //{
            //	x.Name = "--count-commands";
            //	x.processEvent = async (msg, e, success, t) =>
            //	{
            //		if (success)
            //		{
            //			using (var context = new MikiContext())
            //			{
            //				User user = await User.GetAsync(context, msg.Author);
            //				CommandUsage u = await CommandUsage.GetAsync(context, msg.Author.Id.ToDbLong(), e.Name);

            //				u.Amount++;
            //				user.Total_Commands++;

            //				await CommandUsage.UpdateCacheAsync(user.Id, e.Name, u);
            //				await context.SaveChangesAsync();
            //			}
            //		}
            //	};
            //});
        }
Exemplo n.º 5
0
        public FunModule(Module m, Framework.Bot b)
        {
            ImageboardProviderPool.AddProvider(new ImageboardProvider <E621Post>(new ImageboardConfigurations
            {
                QueryKey          = new Uri("http://e621.net/post/index.json?tags="),
                ExplicitTag       = "rating:e",
                QuestionableTag   = "rating:q",
                SafeTag           = "rating:s",
                NetUseCredentials = true,
                NetHeaders        = new List <Tuple <string, string> >()
                {
                    new Tuple <string, string>("User-Agent", "Other"),
                },
                BlacklistedTags =
                {
                    "loli",
                    "shota",
                }
            }));
            ImageboardProviderPool.AddProvider(new ImageboardProvider <DanbooruPost>(new ImageboardConfigurations
            {
                QueryKey          = new Uri("https://danbooru.donmai.us/posts.json?tags="),
                ExplicitTag       = "rating:e",
                QuestionableTag   = "rating:q",
                SafeTag           = "rating:s",
                NetUseCredentials = true,
                NetHeaders        =
                {
                    new Tuple <string, string>("Authorization", $"Basic {Convert.ToBase64String(Encoding.UTF8.GetBytes(Global.Config.DanbooruCredentials))}"),
                },
                BlacklistedTags =
                {
                    "loli",
                    "shota"
                }
            }));
            ImageboardProviderPool.AddProvider(new ImageboardProvider <GelbooruPost>(new ImageboardConfigurations
            {
                QueryKey        = new Uri("http://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&tags="),
                BlacklistedTags =
                {
                    "loli",
                    "shota",
                }
            }));
            ImageboardProviderPool.AddProvider(new ImageboardProvider <SafebooruPost>(new ImageboardConfigurations
            {
                QueryKey        = new Uri("https://safebooru.org/index.php?page=dapi&s=post&q=index&json=1&tags="),
                BlacklistedTags =
                {
                    "loli",
                    "shota",
                }
            }));
            ImageboardProviderPool.AddProvider(new ImageboardProvider <Rule34Post>(new ImageboardConfigurations
            {
                QueryKey        = new Uri("http://rule34.xxx/index.php?page=dapi&s=post&q=index&json=1&tags="),
                BlacklistedTags =
                {
                    "loli",
                    "shota",
                }
            }));
            ImageboardProviderPool.AddProvider(new ImageboardProvider <KonachanPost>(new ImageboardConfigurations
            {
                QueryKey        = new Uri("https://konachan.com/post.json?tags="),
                BlacklistedTags =
                {
                    "loli",
                    "shota",
                }
            }));

            ImageboardProviderPool.AddProvider(new ImageboardProvider <YanderePost>(new ImageboardConfigurations
            {
                QueryKey        = new Uri("https://yande.re/post.json?tags="),
                BlacklistedTags =
                {
                    "loli",
                    "shota",
                }
            }));
        }
Exemplo n.º 6
0
 public InternalModule(Module module, Framework.Bot bot)
 {
 }
Exemplo n.º 7
0
 public ServerCountModule(Module m, Framework.Bot b)
 {
     m.JoinedGuild = OnUpdateGuilds;
     m.LeftGuild   = OnUpdateGuilds;
     //	countLib = new CountLib(ConnectionString);
 }