Example #1
0
            async Task Responce_Unban(string Msg, MessageEventArgs e)
            {
                var Targets = e.Message.MentionedUsers.Where(x => !x.IsBot);

                if (Targets != null)
                {
                    foreach (var U in Targets)
                    {
                        if (UserDatas.GetByUser(U).BanList.Contains(e.User.Id))
                        {
                            UserDatas.GetByUser(U).BanList.Remove(e.User.Id);
                            await e.Channel.SendMessage(e.User.Mention + " removed his vote to **Ban** " + U.Mention + "\nMaking a total of: " + UserDatas.GetByUser(U).BanCount + " / 3 votes");
                        }
                        else
                        {
                            (await e.Channel.SendMessage("You haven't voted to ban " + U.Mention + "\nHe has a total of: " + UserDatas.GetByUser(U).BanCount + " / 3 votes")).Timed(120);
                        }
                    }
                }
                else
                {
                    (await e.Channel.SendMessage(":anger: Could not find a user")).Timed(40);
                    WriteLine("Command Error: Could not determine a user");
                    return;
                }
            }
Example #2
0
            async Task Responce_Pref(string Msg, MessageEventArgs e)
            {
                // Automove
                if (('-' + Msg).CommandCheck("automove"))
                {
                    UserDatas.GetByUser(e.User).AutoMove = !UserDatas.GetByUser(e.User).AutoMove;
                    await e.Channel.SendMessage(e.User.Mention + ", your **Automove** preference has been changed to `" + ((UserDatas.GetByUser(e.User).AutoMove) ? "allow`" : "do not allow`"));

                    WriteLine("Command: Changed " + e.User.Name + "'s Automove pref to " + UserDatas.GetByUser(e.User).AutoMove.ToString());
                }
                // AFKMove
                else if (('-' + Msg).CommandCheck("afkmove"))
                {
                    UserDatas.GetByUser(e.User).AFKMove = !UserDatas.GetByUser(e.User).AFKMove;
                    await e.Channel.SendMessage(e.User.Mention + ", your **AFKmove** preference has been changed to `" + ((UserDatas.GetByUser(e.User).AFKMove) ? "allow`" : "do not allow`"));

                    WriteLine("Command: Changed " + e.User.Name + "'s AFKmove pref to " + UserDatas.GetByUser(e.User).AFKMove.ToString());
                }
                // DoNotTrack
                else if (('-' + Msg).CommandCheck("track"))
                {
                    UserDatas.GetByUser(e.User).AFKMove = !UserDatas.GetByUser(e.User).Track;
                    await e.Channel.SendMessage(e.User.Mention + ", your **Track** preference has been changed to `" + ((UserDatas.GetByUser(e.User).Track) ? "allow tracking`" : "do not track`"));

                    WriteLine("Command: Changed " + e.User.Name + "'s Track pref to " + UserDatas.GetByUser(e.User).Track.ToString());
                }
                else
                {
                    (await e.Channel.SendMessage(":anger: Could not determine what preference you meant, " + e.User.Mention)).Timed(60);
                    WriteLine("Command Error: Could not determine preference");
                }
            }
Example #3
0
        public static void ShadowBan(this User U)
        {
            var Dat = UserDatas.GetByUser(U);

            Dat.BanList = new List <ulong>();
            Dat.TotalBans++;
            Dat.UnbanTime = DateTime.Now.AddDays(2 * Dat.TotalBans);
            U.Edit(true, true, null, new Role[] { CodeSelBot.CodeSEL.GetRole(Role_Banned) }, U.Name + " - BANNED");
        }
Example #4
0
            async Task Responce_Info(string Msg, MessageEventArgs e)
            {
                var U = e.Message.MentionedUsers.FirstOrDefault();

                if (U == null)
                {
                    if (Msg == "")
                    {
                        (await e.Channel.SendMessage(":anger: Could not find a user")).Timed(40);
                        WriteLine("Command Error: Could not determine a user");
                    }
                    else
                    {
                        (await e.Channel.SendMessage("You might be confusing `-info` with `-help <command>`")).Timed(60);
                    }
                    return;
                }
                await e.Channel.SendMessage(UserDatas.GetByUser(U).ToString());
            }
Example #5
0
            private void TimeLooper(object sender, ElapsedEventArgs e)
            {
                if (CodeSEL == null || ConnectionState != "Connected")
                {
                    return;
                }

                BotData.UpTime += TimeSpan.TicksPerSecond;

                foreach (var U in CodeSEL.Users)
                {
                    if (U.Status != "offline")
                    {
                        UserDatas.GetByUser(U).LastOnline = DateTime.Now;
                        if (UserDatas.GetByUser(U).OnlineSince.ToString() == "01-Jan-01 12:00:00 AM")
                        {
                            UserDatas.GetByUser(U).OnlineSince = DateTime.Now;
                        }
                    }
                    else
                    {
                        UserDatas.GetByUser(U).OnlineSince = DateTime.Parse("01-Jan-01 12:00:00 AM");
                    }

                    if (U.CurrentGame.HasValue && !UserDatas.GetByUser(U).Games.Contains(U.CurrentGame.Value.Name))
                    {
                        UserDatas.GetByUser(U).Games.Add(U.CurrentGame.Value.Name);
                    }
                }

                foreach (var VChannel in CodeSEL.VoiceChannels.Where(c => c.Users.Count() > 0))
                {
                    var counter = new Dictionary <ulong, int>();
                    foreach (var v in Dictionaries.VChannels.Values)
                    {
                        counter.Add(v, 0);
                    }

                    foreach (var u in VChannel.Users)
                    {
                        if (u.CurrentGame.HasValue && u.CurrentGame.Value.Name.GetChannel() != null)
                        {
                            counter[u.CurrentGame.Value.Name.GetChannel().Id]++;
                        }
                    }

                    var TargetChannel = CodeSEL.GetChannel(counter.Where(y => y.Value == counter.Values.Max()).FirstOrDefault().Key);
                    if (counter.Values.Max() >= Math.Max(1, VChannel.Users.Count() / 2) &&
                        TargetChannel != VChannel && VChannel.Users.All(x => UserDatas.GetByUser(x).CurrentGame != TargetChannel.Id))
                    {
                        foreach (var u in VChannel.Users)
                        {
                            if ((UserDatas.GetByUser(u).AutoMove) &&
                                (u.VoiceChannel != CodeSEL.AFKChannel || UserDatas.GetByUser(u).AFKMove))
                            {
                                if (!(VChannel.Id == CodeSEL.AFKChannel.Id && (!u.CurrentGame.HasValue || u.CurrentGame.Value.Name.GetChannel().Id != TargetChannel.Id)))
                                {
                                    u.Edit(null, null, TargetChannel);
                                    UserDatas.GetByUser(u).CurrentGame = TargetChannel.Id;
                                    UserDatas.GetByUser(u).TimesMoved++;
                                }
                            }
                            else if (VChannel.Users.Count() > 1)
                            {
                                (CodeSEL.DefaultChannel.SendMessage(u.Mention + ", you have not been moved automatically due to your **AutoMove** preferences")).Timed(100);
                            }
                        }
                    }
                    else if ((VChannel.Id != Dictionaries.Ch_V_Main &&
                              VChannel.Id != Dictionaries.Ch_V_AFK &&
                              VChannel.Id != Dictionaries.Ch_V_Music) &&
                             VChannel.Users.Count() > 0 &&
                             VChannel.Users.All(u => !u.CurrentGame.HasValue ||
                                                (u.CurrentGame.Value.Name.GetChannel() != null &&
                                                 u.CurrentGame.Value.Name.GetChannel().Id != u.VoiceChannel.Id)))
                    {
                        foreach (var u in VChannel.Users)
                        {
                            if (UserDatas.GetByUser(u).AutoMove)
                            {
                                u.Edit(null, null, CodeSEL.GetChannel(Dictionaries.Ch_V_Main));
                                UserDatas.GetByUser(u).CurrentGame = 0;
                                UserDatas.GetByUser(u).TimesMoved++;
                            }
                        }
                    }
                }
            }
Example #6
0
            private async void OnMessage(object sender, MessageEventArgs e)
            {
                if (e.Message.RawText != "")
                {
                    foreach (var C in Commands)
                    {
                        if ((C.AcceptBotMsgs || !e.User.IsBot) && C.Check(e))
                        {
                            if (C.Permission.Count == 0 || (e.User.Roles.Any(x => C.Permission.Any(y => y == x.Id))))
                            {
                                BotData.CommandsProccessed++;
                                if (!C.AllowPrivateChannels && e.Channel.IsPrivate)
                                {
                                    await e.Channel.SendMessage($"The **{C.Name}** command is not available in private chat");
                                }
                                else
                                {
                                    if (C.DeleteMsg)
                                    {
                                        e.Message.Timed(5);
                                    }
                                    WriteLine(C.Name + " Command found in | " + e.Message);
                                    await C.Action(e.Message.RawText.Decrypt(C.Triggers), e);

                                    if (C.Breaks)
                                    {
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                (await e.Channel.SendMessage("You do not have the correct permissions to use this command")).Timed(60);
                            }
                        }

                        // In case of role selection
                        if (e.User.Roles.Count() == 1 && e.Message.MentionedRoles != null && e.Message.MentionedRoles.Count() > 0)
                        {
                            var Msg   = e.User.Mention + ", you've been given the ";
                            var Roles = e.Message.MentionedRoles.Where(x => x.Name.Contains("Buddy"));
                            foreach (var R in Roles)
                            {
                                Msg += R.Mention + "  ";
                            }
                            await e.Channel.SendMessage(Msg);

                            await e.User.Edit(null, null, null, Roles);
                        }
                    }
                }
                UserDatas.GetByUser(e.User).MessagesSent++;
                UserDatas.GetByUser(e.User).CharactersSent += e.Message.RawText.Length;
                if (Listening)
                {
                    if (e.Message.RawText != "")
                    {
                        WriteLine($"#{e.Channel.Name} {e.User.Name}: {e.Message.RawText}");
                    }
                    else
                    {
                        WriteLine($"#{e.Channel.Name} {e.User.Name}: File Sent");
                    }
                }
            }
Example #7
0
            async Task Responce_Exile(string Msg, MessageEventArgs e)
            {
                User Target = e.Message.MentionedUsers.FirstOrDefault();
                var  Time   = 0;              // in Seconds.

                if (Target == null)
                {
                    (await e.Channel.SendMessage(":anger: Missing target user for exile\n`Syntax Error`")).Timed(30);
                    WriteLine("Command Error: Could not find target user");
                    return;
                }
                if (Target.Id == Dictionaries.Bot_ID)
                {
                    (await e.Channel.SendMessage("I can't exile myself :grey_exclamation:")).Timed(30);
                    WriteLine("Command Error: Target can not be the Bot");
                    return;
                }
                if (Target.Roles.Any(x => x.Id == Dictionaries.Role_ServerBot || x.Id == Dictionaries.Role_ServerOwner))
                {
                    (await e.Channel.SendMessage("**" + Target.Name + "** is beyond my reach :cry: ")).Timed(30);
                    WriteLine("Command Error: Target is beyond the Bot's reach");
                    return;
                }
                try
                {
                    Msg = Msg.RemoveMentions().RemoveSpaces();
                    if (!Msg.Contains('#'))
                    {
                        Time = 300;
                    }
                    else
                    {
                        if (Msg.Contains(':'))
                        {
                            Time += int.Parse(Msg.Substring(Msg.IndexOf(':') + 1));
                            if (Msg.Between('#', ':') != "")
                            {
                                Time += 60 * int.Parse(Msg.Between('#', ':'));
                            }
                        }
                        else
                        {
                            Time += 60 * int.Parse(Msg.Substring(Msg.IndexOf('#') + 1));
                        }
                    }
                }
                catch (Exception) { (await e.Channel.SendMessage(":anger: could not determine Exile time\n`Syntax Error`")).Timed(30); WriteLine("Command Error: Could not determine exile time"); return; }

                UserDatas.GetByUser(Target).ExileTime += Time;
                if (Exiles.Any(x => x.User == Target))
                {
                    Exiles.Where(w => w.User == Target).FirstOrDefault().AddTime(Time);
                    WriteLine("Command: Added " + Time + " seconds to " + Target.Name + "'s exile");
                }
                else
                {
                    Exiles.Add(new Exile()
                    {
                        User = Target, ExpireTime = DateTime.Now.AddSeconds(Time), e = e, Timeleft = Time
                    });
                    var ExileTarget = Exiles.Last();
                    ExileTarget.ExileUser();
                    ExileTarget.Timer.Start();
                    ExileTarget.Timer.Disposed += (S, E) =>
                    {
                        while (ConnectionState != "Connected")
                        {
                            System.Threading.Thread.Sleep(500);
                        }
                        ExileTarget.UnexileUser();
                        Exiles.Remove(ExileTarget);
                    };
                    WriteLine("Command: Exiled " + Target.Name + " for " + Time + " seconds");
                }
            }