Exemple #1
0
        public static async Task <string> GetEmojiCommand(ulong id, string name, ulong userId)
        {
            ulong     abid  = Apis.Discord.__client.CurrentUser.Id;
            AbbyTable table = await AbbySql.AbbysqlClient.FetchSQL($"SELECT GelbooruCommandJson FROM abbybooru.emojis WHERE `AbbybotId`='{abid}' AND  `MessageId`='{id}' AND `Emoji`='{name}' AND `OwnerId`='{userId}';");

            return(table.Count > 0 && table[0]["GelbooruCommandJson"] is string i ? i : null);
        }
Exemple #2
0
        public static async Task <int> GetEmojiType(ulong messageId, string emoji, ulong ownerId)
        {
            ulong     abid  = Apis.Discord.__client.CurrentUser.Id;
            AbbyTable table = await AbbySql.AbbysqlClient.FetchSQL($"SELECT * FROM abbybooru.emojis WHERE `AbbybotId`='{abid}' AND  `MessageId`='{messageId}' AND `Emoji`='{emoji}' AND `OwnerId`='{ownerId}';");



            return(table.Count > 0 && table[0]["Type"] is int i ? i : -1);
        }
        public static async Task <List <ulong> > GetListAutoFcDmsAsync()
        {
            List <ulong> fcdms = new List <ulong>();
            AbbyTable    table = await AbbysqlClient.FetchSQL($"select * from `user`.`autofcdms` where `On` = 1;");

            foreach (AbbyRow ar in table)
            {
                fcdms.Add((ulong)ar["UserId"]);
            }
            return(fcdms);
        }
        public static async Task <List <ulong> > GetLatestMentionIdsAsync(ulong id)
        {
            List <ulong> ids = new List <ulong>();

            AbbyTable table = await AbbysqlClient.FetchSQL($"SELECT * FROM heardtweets WHERE Id = {id};");

            foreach (AbbyRow row in table)
            {
                ids.Add((ulong)row["Id"]);
            }
            return(ids);
        }
        public static async Task <(string fc, bool nsfw)> GetFCMAsync(ulong guildId, ulong channelId)
        {
            AbbyTable table = await AbbysqlClient.FetchSQL($"select * from `channel`.`fcsettings` where `GuildId`= {guildId} and `ChannelId` = {channelId};");

            if (table.Count >= 1)
            {
                var fc   = (table[0]["FavoriteCharacter"] is string s && s.Length > 1) ? s : "NO";
                var nsfw = table[0]["IsNSFW"] is int nsf && nsf == 1;
                return(fc, nsfw);
            }
            return("NO", false);
        }
Exemple #6
0
        public static async Task <List <ulong> > GetAbbybotIdAsync()
        {
            List <ulong> abbybots = new List <ulong>();

            AbbyTable table = await AbbysqlClient.FetchSQL($"select * from `abbybot`.`discordbots`");

            foreach (AbbyRow row in table)
            {
                abbybots.Add(table.Count >= 1 && (row["Id"] is ulong u) ? u : 0);
            }
            abbybots.Remove(Apis.Discord.__client.CurrentUser.Id);
            return(abbybots);
        }
Exemple #7
0
        public static async Task <List <(ulong guildId, ulong channelId)> > GetAbbybotChannelIdAsync()
        {
            List <(ulong guildId, ulong channelId)> abbybots = new List <(ulong guildId, ulong channelId)>();

            AbbyTable table = await AbbysqlClient.FetchSQL($"select * from `abbybot`.`channels`");

            foreach (AbbyRow row in table)
            {
                var guild   = table.Count >= 1 && (row["GuildId"] is ulong g) ? g : 0;
                var channel = table.Count >= 1 && (row["ChannelId"] is ulong c) ? c : 0;
                abbybots.Add((guild, channel));
            }
            return(abbybots);
        }
        public static async Task SetAutoFcDmAsync(ulong userId, bool FCMentions)
        {
            int fcm = FCMentions ? 1 : 0;

            AbbyTable table = await AbbysqlClient.FetchSQL($"select * from `user`.`autofcdms` where `UserId` = {userId}");

            if (table.Count < 1)
            {
                await AbbysqlClient.RunSQL($"insert into `user`.`autofcdms` (`UserId`, `On`) values ('{userId}','{fcm}');");

                return;
            }
            await AbbysqlClient.RunSQL($"UPDATE `user`.`autofcdms` SET `On`= '{fcm}' WHERE  `UserId`= {userId};");
        }
        public static async Task SetCFCAsync(ulong guildId, ulong channelId, bool nsfw, string fc)
        {
            string    fcm   = AbbysqlClient.EscapeString(fc);
            int       insfw = nsfw ? 1 : 0;
            AbbyTable table = await AbbysqlClient.FetchSQL($"select * from `channel`.`fcsettings` where `GuildId` = {guildId} and `ChannelId`= {channelId}");

            if (table.Count < 1)
            {
                await AbbysqlClient.RunSQL($"insert into `channel`.`fcsettings` (`GuildId`, `ChannelId`, `FavoriteCharacter`,`IsNSFW` ) values ('{guildId}', '{channelId}', '{fcm}', {insfw});");
            }
            else
            {
                await AbbysqlClient.RunSQL($"UPDATE `channel`.`fcsettings` SET `FavoriteCharacter`= '{fcm}' WHERE  `GuildId`= {guildId} and `ChannelId` = {channelId};");
            }
        }
        public static async Task <List <(ulong guildId, ulong roleId)> > GetRoles()
        {
            List <(ulong guildId, ulong roleId)> roleIds = new List <(ulong guildId, ulong roleId)>();
            AbbyTable table = await AbbysqlClient.FetchSQL($"select * from `guild`.`mostactiveroles`;");

            if (table != null)
            {
                foreach (AbbyRow row in table)
                {
                    var g = row["GuildId"] is ulong guild ? guild : 0;
                    var u = row["RoleId"] is ulong role ? role : 0;
                    roleIds.Add((g, u));
                }
            }
            return(roleIds);
        }
Exemple #11
0
        public override async Task DoWork(AbbybotCommandArgs aca)
        {
            AbbyTable table = await AbbySql.AbbysqlClient.FetchSQL("select * from jokes");

            if (table.Count == 0)
            {
                return;
            }

            int i = aca.AbbyRngRoll(0, table.Count);

            await aca.Send(table[i]["Joke"] is string joke?joke : "");

            await Task.Delay(1000);

            await aca.Send(table[i]["punchline"] is string pl?pl : "");
        }
        public static async Task <Image> Peek()
        {
            Image     image = null;
            AbbyTable table = await AbbysqlClient.FetchSQL($"SELECT * FROM `twitter`.`images`ORDER BY Id LIMIT 1;");

            foreach (AbbyRow row in table)
            {
                image = new Image
                {
                    id        = (int)row["Id"],
                    url       = (row["ImgUrl"] is string i) ? i : "",
                    sourceurl = (row["ImgUrl"] is string s) ? s : "",
                    gelId     = row["GelId"] is int isi ? isi : 0,
                    md5       = row["md5"] is string md5 ? md5 : ""
                };
            }
            return(image);
        }
    }
Exemple #13
0
        public static async Task <List <(ulong Id, DateTime Time, string Info, string FavoriteCharacter, string type, ulong userId, ulong UndoId)> > GetFavoriteCharacterHistoryAsync(ulong userId)
        {
            List <(ulong Id, DateTime Time, string Info, string FavoriteCharacter, string type, ulong userId, ulong UndoId)> fch = new List <(ulong Id, DateTime Time, string Info, string FavoriteCharacter, string type, ulong userId, ulong UndoId)>();
            AbbyTable table = await AbbysqlClient.FetchSQL($"select * from `abbybooru`.`userfchistory` where `UserId`='{userId}' order by `Id`desc limit 5 ");

            foreach (AbbyRow row in table)
            {
                Console.Write("id");
                ulong id = row["Id"] is ulong idid ? idid : 0;

                Console.Write("userid");
                ulong user = row["UserId"] is ulong uid ? uid : 0;

                Console.Write("userid");
                ulong UndoId = row["UndoId"] is ulong uunid ? uunid : 0;

                DateTime dt = new DateTime();

                Console.Write("time");
                try
                {
                    string timestr = row["Time"] is string timest ? timest : "";
                    dt = DateTime.Parse(timestr);
                }
                catch { }

                Console.Write("type");
                string typ = row["Type"] is string typest ? typest : "";

                Console.Write("FavoriteCharacter");
                string FC = row["FavoriteCharacter"] is string fc ? fc : "";

                Console.Write("info");
                string info = row["Info"] is string i ? i : "";

                Console.Write("^ADDING^");
                fch.Add((id, dt, info, FC, typ, user, UndoId));
            }

            return(fch);
        }
Exemple #14
0
        public static async Task <List <FunAbbybotFact> > GetFactsList(bool v, string origin = "all")
        {
            List <FunAbbybotFact> faf = new List <FunAbbybotFact>();
            StringBuilder         sb  = new StringBuilder($"SELECT * FROM facts WHERE `origin` = '{origin}'");

            if (!v)
            {
                sb.Append(" AND `Lewd` = '0'");
            }
            sb.Append(';');
            AbbyTable table = await AbbysqlClient.FetchSQL(sb.ToString());

            if (table.Count > 0)
            {
                foreach (AbbyRow row in table)
                {
                    faf.Add(new FunAbbybotFact
                    {
                        id   = row["Id"] is ulong u ? u : 0,
                        fact = (row["Fact"] is string i) ? i : ""
                    });
        public static async Task <ulong> GetRole(ulong guildId)
        {
            AbbyTable t = await AbbysqlClient.FetchSQL($"select *  from `guild`.`mostactiveroles` where `GuildId`='{guildId}';");

            return(t.Count > 0 ? t[0]["roleId"] is ulong u ? u : 0 : 0);
        }
Exemple #16
0
        public static async Task <bool> GetAutoFcDmAsync(ulong userId)
        {
            AbbyTable table = await AbbysqlClient.FetchSQL($"select * from `user`.`autofcdms` where `UserId` = {userId}");

            return(table.Count >= 1 && (table[0]["On"] is sbyte sba) && ((int)sba == 1));
        }
        public static async Task <bool> RemoveRole(ulong guildId, ulong roleId)
        {
            AbbyTable t = await AbbysqlClient.FetchSQL($"select *  from `guild`.`mostactiveroles` where `GuildId`='{guildId}';");

            return(t.Count switch
            {
Exemple #18
0
        public static async Task <bool> GetFCMAsync(ulong userId)
        {
            AbbyTable table = await AbbysqlClient.FetchSQL($"select * from `abbybooru`.`userfcmentions` where `UserId` = {userId}");

            return(table.Count >= 1 && (((sbyte)table[0]["FCM"]) == 1));
        }