Пример #1
0
        public static void DelFoodOption(string krz)
        {
            DataTable foodOptionsTable = Jenkins.Database.Tables["FOODOPTIONS"];

            foodOptionsTable.Rows.Find(krz).Delete();
            Jenkins.Write();
        }
Пример #2
0
        private static void UpdateSchnautOffers(List <SchnautOffer> offers)
        {
            bool allOffersdeleted = false;
            int  index            = 1;

            while (!allOffersdeleted)
            {
                if (IsValidKRZ("SCHN" + index))
                {
                    DelFoodOption("SCHN" + index);
                    index = index + 1;
                }
                else
                {
                    allOffersdeleted = true;
                }
            }
            index = 1;
            List <string> addedItems = new List <string>();

            foreach (var offer in offers)
            {
                List <Food.Day> dayList = new List <Food.Day>();
                dayList.Add(offer.OfferDay);
                AddFoodOption("SCHN" + index, "Schnaut Launsbach", offer.Desc + " - " + offer.Price + "€", dayList.AsEnumerable(), "Vorbestellen unter 0641 82225");
                addedItems.Add("SCHN" + index);
                index = index + 1;
            }
            Bot.NotifyDevs(Supporter.BuildList("Added offers", addedItems.ToArray()));
            Jenkins.Write();
        }
Пример #3
0
        public void DelGame(string name)
        {
            var gamesTable = Jenkins.Database.Tables["GAMES"].AsEnumerable();

            gamesTable.Where(r => r.Field <ulong>("NAME").Equals(name)).First().Delete();
            Jenkins.Write();
        }
Пример #4
0
        public void DelVictim(ulong userId)
        {
            DataRow victimRow = Jenkins.Database.Tables["INSULTVICTIMS"].Rows.Find(userId);

            victimRow.Delete();
            Jenkins.Write();
        }
Пример #5
0
        public void AddUser(User user)
        {
            Random rnd = new Random();

            Jenkins.Database.Tables["USERS"].Rows.Add(user.Name, user.Id);
            Jenkins.Database.Tables["USERSTATS"].Rows.Add(user.Id, 0, 0, DateTime.Now, 0, rnd.Next(0, 100), DateTime.Now);
            Jenkins.Write();
        }
Пример #6
0
 public void AddGame(string name, bool isRestricted)
 {
     if (!Jenkins.Database.Tables["GAMES"].Rows.Contains(name))
     {
         Jenkins.Database.Tables["GAMES"].Rows.Add(name, isRestricted);
         Jenkins.Write();
     }
 }
Пример #7
0
        public void AddTwitchChannel(JObject channelObject)
        {
            int    id   = int.Parse(channelObject.GetValue("_id").ToString());
            string name = channelObject.GetValue("display_name").ToString();
            string logo = channelObject.GetValue("logo").ToString();

            Jenkins.Database.Tables["TWITCHCHANNELS"].Rows.Add(id, name, logo, DateTime.Now);
            Jenkins.Write();
        }
Пример #8
0
        public void AddTwitchChannelToWatchlistOfDiscordChannel(string twitchChannelName, User user, Channel txtChannel)
        {
            int   id        = GetTwitchChannelIdByName(twitchChannelName);
            ulong userId    = user.Id;
            ulong channelId = txtChannel.Id;

            Jenkins.Database.Tables["TWITCHDISCORDCHANNELS"].Rows.Add(id, channelId, userId, DateTime.Now);
            Jenkins.Write();
        }
Пример #9
0
        public void AddServer(ulong id)
        {
            Server server;

            if (Supporter.TryGetServerById(id, out server))
            {
                Jenkins.Database.Tables[TblName].Rows.Add(server.Id);
                Jenkins.Write();
            }
        }
Пример #10
0
        public static void AddServer(string name)
        {
            Server server;

            if (TryGetServerByName(name, out server))
            {
                Jenkins.Database.Tables["OBSERVE"].Rows.Add(server.Id, server.Name);
                Jenkins.Write();
            }
        }
Пример #11
0
        public void DegradeToUser(ulong userId, ulong serverId)
        {
            var admins = Jenkins.Database.Tables["ADMINS"].AsEnumerable();
            var admin  = admins
                         .Where(r => r.Field <ulong>("USERID").Equals(userId))
                         .Where(r => r.Field <ulong>("SERVERID").Equals(serverId));

            admin.ElementAt(0).Delete();
            Jenkins.Write();
        }
Пример #12
0
        public void AddStream(JObject streamObject, JObject channelObject)
        {
            ulong  id      = ulong.Parse(streamObject.GetValue("_id").ToString());
            string channel = channelObject.GetValue("display_name").ToString();;
            string game    = streamObject.GetValue("game").ToString();
            string url     = channelObject.GetValue("url").ToString();

            Jenkins.Database.Tables["TWITCHSTREAMS"].Rows.Add(id, channel, game, url, DateTime.Now);
            Jenkins.Write();
        }
Пример #13
0
        public void UpdateLastActivity(User user)
        {
            string   userEXP      = string.Format("USERID = '{0}'", user.Id);
            DataRow  row          = Jenkins.Database.Tables["USERSTATS"].Rows.Find(user.Id);
            DateTime lastActivity = DateTime.Parse(row["LASTACTIVITY"].ToString());

            lastActivity        = DateTime.Now;
            row["LASTACTIVITY"] = lastActivity;
            row.AcceptChanges();
            Jenkins.Write();
        }
Пример #14
0
        public static void DelServer(string name)
        {
            var   observingTable = Jenkins.Database.Tables["OBSERVE"].AsEnumerable();
            ulong serverId       = 0;

            if (TryGetServerIdByName(name, out serverId))
            {
                observingTable.Where(r => r.Field <ulong>("SERVERID").Equals(serverId)).First().Delete();
                Jenkins.Write();
            }
        }
Пример #15
0
        public void DelServer(ulong id)
        {
            var    serversTable = Jenkins.Database.Tables[TblName].AsEnumerable();
            Server server;

            if (Supporter.TryGetServerById(id, out server))
            {
                serversTable.Where(r => r.Field <ulong>("SERVERID").Equals(id)).First().Delete();
                Jenkins.Write();
            }
        }
Пример #16
0
        public string DelWebsite(string keyword)
        {
            var websites = Jenkins.Database.Tables["WEBSITES"].AsEnumerable().Where(ws => ws.Field <string>("URL").ToLower().Contains(keyword.ToLower()));

            if (websites.Count() == 1)
            {
                websites.First().Delete();
                Jenkins.Write();
                return("`" + websites.First().Field <string>("URL") + "` was deleted");
            }
            return("No website found for **" + keyword + "**");
        }
Пример #17
0
        public void DelQuote(User user, int index, ulong serverId)
        {
            DataTable quotesTable = Jenkins.Database.Tables["QUOTES"];
            var       quotes      = quotesTable.AsEnumerable();

            if (!Jenkins.Users.IsUserAdmin(user.Id, serverId))
            {
                quotes = quotes.Where(r => r.Field <string>("USERID").Equals(user.Id));
            }
            quotes.ElementAt <DataRow>(index).Delete();
            Jenkins.Write();
        }
Пример #18
0
        public void PromoteToAdmin(ulong userId, ulong serverId)
        {
            var admin = Jenkins.Database.Tables["ADMINS"].AsEnumerable()
                        .Where(r => r.Field <ulong>("USERID").Equals(userId))
                        .Where(r => r.Field <ulong>("SERVERID").Equals(serverId));

            if (admin.Count() >= 1)
            {
                return;
            }
            Jenkins.Database.Tables["ADMINS"].Rows.Add(userId, serverId, false);
            Jenkins.Write();
        }
Пример #19
0
        public void RemoveTwitchChannelFromWatchlistOfDiscordChannel(string channelName, Channel txtChannel)
        {
            var   twitchChannels  = Jenkins.Database.Tables["TWITCHCHANNELS"].AsEnumerable();
            var   twitchChannel   = twitchChannels.Where(r => r.Field <string>("NAME").Equals(channelName));
            int   twitchChannelId = twitchChannel.FirstOrDefault().Field <int>("ID");
            ulong channelId       = txtChannel.Id;

            Jenkins.Database.Tables["TWITCHDISCORDCHANNELS"].Rows.Find(twitchChannelId).Delete();
            if (GetFollowingDiscordChannelsForTwitchChannel(channelName).Length == 0 && false) // ToDo: Exception wenn Datensatz gelöscht wird während Requests für den entsprechenden Twitch-Channel ausgeführt werden
            {
                DelTwitchChannel(channelName);
            }
            Jenkins.Write();
        }
Пример #20
0
 public void DelInsult(User user, int index, ulong serverId)
 {
     DataRow[] userRows;
     if (Jenkins.Users.IsUserAdmin(user.Id, serverId))
     {
         userRows = Jenkins.Database.Tables["INSULTS"].Select("");
     }
     else
     {
         string userEXP = string.Format("USERID = '{0}'", user.Id);
         userRows = Jenkins.Database.Tables["INSULTS"].Select(userEXP);
     }
     userRows.ElementAt <DataRow>(index).Delete();
     Jenkins.Write();
 }
Пример #21
0
        public void DelTwitchChannel(string channelName)
        {
            if (GetFollowingDiscordChannelsForTwitchChannel(channelName).Length != 0) // Should not happen
            {
                Console.WriteLine("Detected (system-architecture ?) failure in Twitch.cs:");
                Console.WriteLine("Tried to delete Twitch-Channel " + channelName + " while it still got following Discord-Channels:");
                foreach (var discordChannel in GetFollowingDiscordChannelsForTwitchChannel(channelName))
                {
                    Console.WriteLine(discordChannel);
                }
            }
            int twitchChannelId = GetTwitchChannelIdByName(channelName);

            Jenkins.Database.Tables["TWITCHCHANNELS"].Rows.Find(twitchChannelId).Delete();
            Jenkins.Write();
        }
Пример #22
0
        public static void AddFoodOption(string krz, string name, string desc = null, IEnumerable <Day> days = null, string info = null, bool driverRequired = true)
        {
            var table = Jenkins.Database.Tables["FOODOPTIONS"];

            if (table.Rows.Find(krz) != null)
            {
                return;
            }
            if (desc == "")
            {
                desc = null;
            }

            string daysString = null;

            if (days.Count() == 0)
            {
                days = null;
            }
            else
            {
                foreach (var day in days)
                {
                    daysString = daysString + day.ToString() + ", ";
                }
                daysString = daysString.Remove(daysString.Length - 2);
            }

            if (info == "")
            {
                info = null;
            }

            table.Rows.Add(krz, name, desc, daysString, info, driverRequired);
            Jenkins.Write();
        }
Пример #23
0
 public void AddInsult(User user, string message)
 {
     Jenkins.Database.Tables["INSULTS"].Rows.Add(user.Id, message, DateTime.Now);
     Jenkins.Write();
 }
Пример #24
0
 public void AddWebsite(string url, string tags = "")
 {
     Jenkins.Database.Tables["WEBSITES"].Rows.Add(url, tags.ToLower(), tags.Contains("nsfw") ? true : false);
     Jenkins.Write();
 }
Пример #25
0
 public void AddQuote(User user, string message, string owner)
 {
     Jenkins.Database.Tables["QUOTES"].Rows.Add(user.Id, message, owner, DateTime.Now);
     Jenkins.Write();
 }
Пример #26
0
 public void AddVictim(ulong userId)
 {
     Jenkins.Database.Tables["INSULTVICTIMS"].Rows.Add(userId);
     Jenkins.Write();
 }