示例#1
0
        public static void AnnounceTimeUntilRaid(Message triggerMessage)
        {
            var raidDays = new List<DayOfWeek>
            {
                DayOfWeek.Monday,
                DayOfWeek.Thursday,
                DayOfWeek.Sunday
            };

            const int raidHourUtc = 19;
            const int raidMinuteUtc = 0;

            var nowUtc = DateTime.UtcNow;
            var nextRaidUtc = DateTime.Today.AddHours(raidHourUtc).AddMinutes(raidMinuteUtc);


            while (!raidDays.Contains(nextRaidUtc.DayOfWeek))
            {
                nextRaidUtc = nextRaidUtc.AddDays(1);
            }

            var timeUntilNextRaid = nextRaidUtc - nowUtc;

            triggerMessage.Channel.SendMessage(string.Format("The next raid should be in {0} days, {1} hours, and {2} minutes, {3}.",
                    timeUntilNextRaid.Days, timeUntilNextRaid.Hours, timeUntilNextRaid.Minutes,
                    triggerMessage.User.GetUserName()));
        }
		public CommandEventArgs(Message message, Command command, string commandText, int? permissions, string[] args)
		{
			Message = message;
			Command = command;
			CommandText = commandText;
			Permissions = permissions;
			Args = args;
		}
示例#3
0
 public  async void ExecuteCommand(Channel channel, Message message)
 {
     await channel.SendIsTyping();
     Thread.Sleep(5000);
     await
         channel.SendMessage(
             "What the f**k did you just f*****g say about me, you little bitch? I’ll have you know I graduated top of my class in the Navy Seals, and I’ve been involved in numerous secret raids on Al-Quaeda, and I have over 300 confirmed kills. I am trained in gorilla warfare and I’m the top sniper in the entire US armed forces. You are nothing to me but just another target. I will wipe you the f**k out with precision the likes of which has never been seen before on this Earth, mark my f*****g words. You think you can get away with saying that shit to me over the Internet? Think again, f****r. As we speak I am contacting my secret network of spies across the USA and your IP is being traced right now so you better prepare for the storm, maggot. The storm that wipes out the pathetic little thing you call your life. You’re f*****g dead, kid. I can be anywhere, anytime, and I can kill you in over seven hundred ways, and that’s just with my bare hands. Not only am I extensively trained in unarmed combat, but I have access to the entire arsenal of the United States Marine Corps and I will use it to its full extent to wipe your miserable ass off the face of the continent, you little shit. If only you could have known what unholy retribution your little “clever” comment was about to bring down upon you, maybe you would have held your f*****g tongue. But you couldn’t, you didn’t, and now you’re paying the price, you goddamn idiot. I will shit fury all over you and you will drown in it. You’re f*****g dead, kiddo.");
 }
示例#4
0
 public MessageList(Discord.Server id, Discord.Message firstMessage, int maxmess)
 {
     server = id;
     list   = new List <Discord.Message>()
     {
         firstMessage
     };
     maxMessages = maxmess;
 }
示例#5
0
        private void incrementPressure(UserProfile up, Discord.Message currentMessage)
        {
            Debug.WriteLine("Last message - " + up.lastMessage.Text);
            Debug.WriteLine("Current message - " + currentMessage.Text);
            double timeSince = TimeSpan.FromTicks(currentMessage.Timestamp.Ticks - up.lastMessage.Timestamp.Ticks).TotalSeconds;
            double factor    = 1;

            if (currentMessage.Text.Equals(up.lastMessage.Text, StringComparison.OrdinalIgnoreCase))
            {
                factor *= 1.3;
            }
            if (currentMessage.Embeds.Length > 0)
            {
                factor *= 1.5;
                Debug.WriteLine("Message had embed.");
            }
            else if (currentMessage.Attachments.Length > 0)
            {
                factor *= 1.5;
                Debug.WriteLine("Message has attatchment.");
            }
            if (currentMessage.IsTTS)
            {
                factor *= 1.5;
            }
            if (currentMessage.Text.Length > 200)
            {
                factor *= 1.5;
            }
            up.pressure -= (getSpamCD(server.Id) * timeSince);
            if (factor < getSpamCD(server.Id) / 2)
            {
                factor = getSpamCD(server.Id) / 2;
            }
            up.pressure += factor;
            if (up.pressure < 0)
            {
                up.pressure = 0;
            }
            up.setMessage(currentMessage);
            Debug.WriteLine("new pressure for " + up.user.Name + ": " + up.pressure);
            if (up.pressure > getSpamLimit(server.Id))
            {
                server.Ban(up.user, 1);
                try
                {
                    server.FindChannels(getLogChannel(server.Id)).FirstOrDefault().SendMessage("Banned user **" + up.user.Name + "** for spam. Last message sent: " + up.lastMessage.Text);
                }
                catch (NullReferenceException)
                {
                    server.Owner.SendMessage("Banned user **" + up.user.Name + "** for spam. Last message sent: " + up.lastMessage.Text + "\nIf you want me to log these to your channel instead of DM, set a log channel with .setlogchannel {channel name}!");
                }
            }
        }
示例#6
0
 public MessageList(Discord.Server id, Discord.Message firstMessage)
 {
     server = id;
     list   = new List <Discord.Message>()
     {
         firstMessage
     };
     userProfiles = new List <UserProfile>()
     {
     };
     maxMessages = 1000;
 }
示例#7
0
        public void add(Discord.Message message)
        {
            list.Add(message);
            int index = findUserProfile(message.User);

            if (index == -1)
            {
                userProfiles.Add(new UserProfile(message.User, 1, message));
                index = userProfiles.Count - 1;
                Debug.WriteLine("added user profile for " + message.User.Name + ". Initialized with message " + userProfiles.ElementAt(index).lastMessage.Text);
            }
            else
            {
                incrementPressure(userProfiles.ElementAt(index), message);
            }
            if (list.Count > maxMessages)
            {
                purge();
            }
        }
        public  async void ExecuteCommand(Channel channel, Message message)
        {
            try
            {


                var regex = Regex.Match(message.Text, "(?<={)[^}]*H(?=})");
                var text = regex.Groups[0].ToString();
                var id = SteamIdentity.FromSteamID(HelperMethods.GetSteamId(text));
                    var builder = new MySqlConnectionStringBuilder
                    {
                        Database = "mediabiz_DiscordBot",
                        Server = "masonsciotti.com",
                        Port = 3306,
                        UserID = "mediabiz_msciott",
                        Password = "******"
                    };
                    var conn = new MySqlConnection(builder.ConnectionString);
                    conn.Open();
                    var command = new MySqlCommand("add_steam_id", conn) {CommandType = CommandType.StoredProcedure};
                    command.Parameters.AddWithValue("DiscordID", message.User.Id);
                    command.Parameters.AddWithValue("SteamID", id.SteamID);
                    command.ExecuteNonQuery();
                    conn.Close();

                    var playerName =
                        SteamWebAPI.General()
                            .ISteamUser()
                            .GetPlayerSummaries(id)
                            .GetResponse()
                            .Data.Players.FirstOrDefault()?
                            .PersonaName;
                    await
                        message.User.SendMessage(
                            $"Thank you, {playerName}! Your steam information has been registered with this bot.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
示例#9
0
        private void RegisterBlockifyCommand()
        {
            command.CreateCommand("blockify")
            .Alias(new string[] { "block" })
            .Description("Turns alphabet characters into \"blocks\"")
            .Parameter("message", ParameterType.Multiple)
            .Do(async(e) =>
            {
                var message = e.Args;
                StringBuilder blockifiedMessage = new StringBuilder();

                try
                {
                    Discord.Message[] messageArr = new Discord.Message[] { e.Message };
                    e.Channel.DeleteMessages(messageArr);
                }
                catch (Exception exc)
                {
                    throw new Exception(exc.Message);
                }
                await e.Channel.SendMessage(e.User.Name + " says: \n\n");

                foreach (string x in message)
                {
                    foreach (char c in x)
                    {
                        if (Char.IsLetter(c))
                        {
                            blockifiedMessage.Append(":regional_indicator_" + Char.ToLower(c) + ": ");
                        }
                        else
                        {
                            blockifiedMessage.Append(c);
                        }
                    }
                    blockifiedMessage.Append("    ");
                }

                await e.Channel.SendMessage(blockifiedMessage.ToString());
            });
        }
示例#10
0
        public  static void AnnounceTimeUntilHoliday(Message triggerMessage)
        {
            var holidayStarts = new DateTime(2016, 7, 1, 15, 30, 0);
            var holidayEnds = new DateTime(2016, 8, 1, 7, 0, 0);

            if (DateTime.Now > holidayStarts && DateTime.Now < holidayEnds)
            {
                triggerMessage.Channel.SendMessage("Vein is currently on holiday! F**k yeah!");
                return;
            }

            if (DateTime.Now > holidayEnds)
            {
                triggerMessage.Channel.SendMessage("Vein's holiday has ended...");
                return;
            }

            var timeLeft = holidayStarts - DateTime.Now;

            triggerMessage.Channel.SendMessage($"Only {timeLeft.Days} days, {timeLeft.Hours} hours, {timeLeft.Minutes} minutes and {timeLeft.Seconds} seconds left until Vein's holiday!");
        }
示例#11
0
        public static void GoogleString(Message triggerMessage)
        {
            var searchTerms = CommandFactory.GetParameters(triggerMessage.RawText);
            var searchString = string.Join(" ", searchTerms);



            const string apiKey = "AIzaSyC1KAPCB759-e4nMRS2dOxm0keFUdGWyY8";
            const string searchEngineId = "008509564598163386467:l2hjjt0senw";
            string query = searchString;

            CustomsearchService customSearchService = new CustomsearchService(new Google.Apis.Services.BaseClientService.Initializer() { ApiKey = apiKey });
            CseResource.ListRequest listRequest = customSearchService.Cse.List(query);
            listRequest.Cx = searchEngineId;

            Search search = listRequest.Execute();


            triggerMessage.Channel.SendMessage($"Here's what I found about \"{searchString}\": \n\n*{search.Items.First().Snippet}* \n\nFor more see: {search.Items.First().Link}");
            triggerMessage.Channel.SendMessage($"Not what you were looking for? https://www.google.com/search?q={string.Join("+", searchTerms)}");
        }
示例#12
0
        public static void ReportEventStats(Message triggerMessage)
        {
            triggerMessage.Channel.SendMessage($"One moment {triggerMessage.User.GetUserName()}, and I'll check.");

            var eventData = GetEventData();

            if (eventData.IsFresh == false)
            {
                if (_socket == null)
                {
                    _socket = new WebSocket("ws://10.0.0.100:29555/");
                    _socket.Opened += (sender, args) => _socket.Send("fetch");
                    _socket.Open();
                }
                else
                {
                    _socket.Send("fetch");
                }
            }

            var retries = 0;
            var maxRetries = 5;
            while (eventData.IsFresh == false && retries < maxRetries)
            {
                System.Threading.Thread.Sleep(2500);
                eventData = GetEventData();
                retries++;
            }

            if (retries == maxRetries)
            {
                triggerMessage.Channel.SendMessage($"Sorry {triggerMessage.User.GetUserName()}, I was unable to get fresh data.");
            }
            else
            {
                triggerMessage.Channel.SendMessage($"{eventData.Accepted} accepted, {eventData.Declined} declined, {eventData.Standby} standby, and {eventData.NoResponse} unsigned for the raid on the {eventData.NextRaidDate}.");
            }
        }
示例#13
0
 public  async void ExecuteCommand(Channel channel, Message message)
 {
     try
     {
         var discordId = message.User.Id;
         var builder = new MySqlConnectionStringBuilder
         {
             Database = "mediabiz_DiscordBot",
             Server = "masonsciotti.com",
             Port = 3306,
             UserID = "mediabiz_msciott",
             Password = "******"
         };
         var conn = new MySqlConnection(builder.ConnectionString);
         conn.Open();
         var command =
             new MySqlCommand($"SELECT steam_id FROM SteamIdRegistration WHERE discord_id = {discordId}", conn);
         var steamId = command.ExecuteScalar();
         var latestMatchId =
             SteamWebAPI.Game()
                 .Dota2()
                 .IDOTA2Match()
                 .GetMatchHistory()
                 .Account(SteamIdentity.FromSteamID(((long) steamId)))
                 .GetResponse()
                 .Data.Matches.FirstOrDefault()?
                 .MatchID;
         await
             channel.SendMessage("Last match for " + message.User.Mention + ": http://www.dotabuff.com/matches/" +
                                 latestMatchId);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
示例#14
0
 public  async void ExecuteCommand(Channel channel, Message message)
 {           
     await channel.SendMessage("https://45.media.tumblr.com/4b38cf29e942d17d2d9ffc761ecca2c0/tumblr_n2jgzxjXxT1tod5n6o1_400.gif");            
 }
示例#15
0
 public async void ExecuteCommand(Channel channel, Message message)
 {
     await channel.SendMessage("http://i.imgur.com/Ek817Gh.jpg");
 }
示例#16
0
 public  void ExecuteCommand(Channel channel, Message message)
 {
     channel.SendMessage(
         "👌👀👌👀👌👀👌👀👌👀 good shit go౦ԁ sHit👌 thats ✔ some good👌👌shit right👌👌there👌👌👌 right✔there ✔✔if i do ƽaү so my self 💯 i say so 💯 thats what im talking about right there right there (chorus: ʳᶦᵍʰᵗ ᵗʰᵉʳᵉ) mMMMMᎷМ💯 👌👌 👌НO0ОଠOOOOOОଠଠOoooᵒᵒᵒᵒᵒᵒᵒᵒᵒ👌 👌👌 👌 💯 👌 👀 👀 👀 👌👌Good shit");
 }
示例#17
0
 private static void AddBotReply(Message bot, Message user)
 {
     while (BotReplies.Count > Program.EditMax)
     {
         Message[] dummy;
         BotReplies.TryDequeue(out dummy);
     }
     BotReplies.Enqueue(new Message[] { bot, user });
 }
示例#18
0
 static string DoPing(Message msg)
    => $" ({DateTime.Now.Millisecond - msg.Timestamp.Millisecond} milliseconds)";
示例#19
0
 public UserProfile(Discord.User u, double p, Discord.Message m)
 {
     user        = u;
     pressure    = p;
     lastMessage = m;
 }
示例#20
0
 async public void ExecuteCommand(Channel channel, Message message)
 {
     await channel.SendMessage("https://i.redd.it/1orjrm27jscx.jpg");
 }
示例#21
0
 public  async void ExecuteCommand(Channel channel, Message message)
 {
     await channel.SendMessage("https://i.imgur.com/dAoVxaM.jpg");
 }
示例#22
0
        public string GetRandomReply(ReplyType replyType, Message message = null)
        {
            var replies = GetRepliesByType(replyType);
            var rnd = new Random().Next(0, replies.Count());

            return (message != null)
                ? string.Format(replies.ElementAt(rnd).Text, Mention.User(message.User))
                : replies.ElementAt(rnd).Text;
        }
示例#23
0
        public string GetReply(Channel channel, Message message)
        {
            var msg = message.RawText.ToLowerInvariant();

            if (IsInsult(msg))
            {
                NotifyReceivedBadMessage(new BadMessageEventArgs { Channel = message.Channel, User = message.User, Reason = "Insulting a bot." });
                return GetRandomReply(ReplyType.Insult, message);
            }

            if (IsThanks(message))
            {
                var targetUser = message.MentionedUsers.ElementAt(0);
                var fromUser = message.User;

                if (fromUser != targetUser)
                {
                    NotifyReceivedThankfulMessage(new ThankfulMessageEventArgs { Channel = message.Channel, FromUser = message.User, ToUser = targetUser });
                }
            }

            if (!message.IsMentioningMe) 
                return null;

            if (IsQuestion(msg))
            {
                if(msg.Contains("why"))
                {
                    return GetRandomReply(ReplyType.Answer, message);
                }

                if(msg.Contains("can you"))
                {
                    return "No.";
                }

                if(msg.Contains("will you"))
                {
                    return "Certainly not.";
                }

                if(msg.Contains("do you like"))
                {
                    return GetRandomReply(ReplyType.Opinion, message);
                }

                if(msg.Contains("do you think"))
                {
                    return GetRandomReply(ReplyType.Opinion, message);
                }

                return GetRandomReply(ReplyType.Unknown, message);
            }

            if(IsGreeting(msg))
            {
                return string.Format("{0} {1}!", GetRandomReply(ReplyType.Greeting, message), Mention.User(message.User));
            }

            return null;
        }
示例#24
0
        private bool IsThanks(Message message)
        {
            var text = message.Text.ToLowerInvariant();
            if ((text.Contains("thanks") || text.Contains("thank you") || text.Contains("ty") || text.Contains("thx")) && message.MentionedUsers.Any())
            {
                return true;
            }

            return false;
        }
示例#25
0
 public  async void ExecuteCommand(Channel channel, Message message)
 {
     await channel.SendMessage("༼ ºل͜º ༽ºل͜º ༽ºل͜º ༽ HEY @everyone GET IN HERE ༼ ºل͜º༼ ºل͜º༼ ºل͜º ༽");
 }
示例#26
0
 public  async void ExecuteCommand(Channel channel, Message message)
 {
     await channel.SendIsTyping();
     Thread.Sleep(5000);
     await channel.SendMessage(@"Whatever kid. Oh I'm sorry did I f*****g trigger you? Were you f*****g triggered you little cry baby? F**k off. Literally saying not a f*****g word to you and you're gonna f*****g mute me because you have a problem with me just f*****g talking shit in all chat? Honestly go f**k yourself to the highest f*****g caliber you f*****g asshole. So sick of little f*****g bitches like you who f*****g have a f*****g opinion like you're f*****g sitting over there like, oh I'm some f*****g problem to you because I'm not even f*****g saying a f*****g word to you. F**k off. Call it what you f*****g asshole? Hormonal? Kid you're a f*****g bullshitter. You're a f*****g bullshitter. Go f**k yourself. You ain't f*****g nothing. You ain't f*****g anyone. You ain't got a f*****g clue in your f*****g head who I am or what I'm f*****g about. That I'm f*****g calling these f*****g kids tryhards, has your f*****g panties in a bunch for what? For what? For f*****g what kid? Honestly I'm f*****g sick of kids like you. Literally go f**k yourself. Go f**k yourself and everything that you f*****g stand for because I'm gonna tell you right now, you don't stand for shit kid. You don't stand for f*****g shit. Please. Yeah, talk in all chat. Yeah like anybody f*****g cares kid go find a f*****g friend to talk to, right? Because you can't f*****g talk to me, you can't f*****g treat me like a f*****g person. You ain't f*****g real kid. You ain't f*****g real. You ain't got a f*****g real f*****g bone in your f*****g body kid. So go f*****g all chat, and make some f*****g friends. Alright? You can make some f*****g friends because ""Oh, this guy's hormonal,"" pffft ""Uh I'm gonna mute him, "" pffft f**k off. You're literally a f*****g cancer on this f*****g world kid. Never f*****g forget it.");
 }
示例#27
0
		private void RaiseMessageSent(Message msg)
		{
			if (MessageSent != null)
				RaiseEvent(nameof(MessageSent), () => MessageSent(this, new MessageEventArgs(msg)));
		}
示例#28
0
 public void setMessage(Discord.Message message)
 {
     Debug.WriteLine("Set last message for user " + user.Name + " to " + message.Text);
     lastMessage = message;
 }
示例#29
0
		internal MessageEventArgs(Message msg) { Message = msg; }
示例#30
0
 public  async void ExecuteCommand(Channel channel, Message message)
 {
     //await channel.SendMessage("http://dota2.cyborgmatt.com/greg/");   
     await channel.SendMessage("https://media.giphy.com/media/l41lI72Me7ojwCPSM/giphy.gif");
 }
示例#31
0
 public  async void ExecuteCommand(Channel channel, Message message)
 {
     await channel.SendMessage("➤ Good game, well played.");
 }
示例#32
0
 public MessageEventArgs(Message msg) { Message = msg; }
示例#33
0
 private static async Task SendReply(object client, Message message, ulong channelId, ulong messageId, string reply)
 {
     DiscordClient cl = (DiscordClient) client;
     if (cl.MessageQueue.Count > 20)
     {
         Console.WriteLine("Too many messages queued at once.");
         return;
     }
     try
     {
         LastHandledMessageOnChannel[channelId] = messageId;
         Message x = await cl.GetChannel(channelId).SendMessage(reply);
         AddBotReply(x, message);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
示例#34
0
        public void ExecuteCommandDiscord(Message message)
        {
            Viewer viewer;
            try
            {
                viewer = MainWindow.colDatabase.FirstOrDefault(x => x.DiscordID == message.User.Id.ToString());
                MainWindow.popMsgBox(viewer.UserName);
            }
            catch (Exception)
            {
                viewer = new Viewer(message.User.Name);
            }
            if (viewer == null)
            {
                return;
            }

            if (CanExecute(viewer))
            {
                Match targetMatch = Regex.Match(message.Text, @"@(?<name>[a-zA-Z0-9_]{4,25})");
                string target = targetMatch.Groups["name"].Value;

                // Parse response line here
                // @user@ -> Display name of the user of the command

                // @followdate@ -> Command user's follow date
                // @followdatetime@ -> Command user's follow date and time

                // @game@ -> Channels current game
                // @title@ -> Channels current title

                string parsedResponse = Regex.Replace(response, @"@(?<item>\w+)@", m =>
                {
                    string[] split = Regex.Split(message.Text, @"\s+");

                    switch (m.Groups["item"].Value.ToLower())
                    {
                        case "user":
                            return viewer.UserName;

                        case "followdate":
                            return viewer.GetFollowDateTime("yyyy-MM-dd");

                        case "followdatetime":
                            return viewer.GetFollowDateTime("yyyy-MM-dd HH:mm");

                        case "game":
                            return Utils.GetClient().GetMyChannel().Game;

                        case "title":
                            return Utils.GetClient().GetMyChannel().Status;

                        case "var1":
                            if (split.Count() == 2)
                            {
                                var1 = split[1];
                                return var1;
                            }
                            return "";

                        default:
                            return "";
                    }
                });

                MainWindow.discord.GetServer(message.Server.Id).GetChannel(message.Channel.Id).SendMessage(parsedResponse.Trim());
            }
        }
示例#35
0
		private void RaiseMessageUpdated(Message msg)
		{
			if (MessageUpdated != null)
				RaiseEvent(nameof(MessageUpdated), () => MessageUpdated(this, new MessageEventArgs(msg)));
		}
示例#36
0
 async public void ExecuteCommand(Channel channel, Message message)
 {
     await channel.SendMessage("http://i.imgur.com/XHBa71T.jpg");
 }
示例#37
0
		private void RaiseMessageReadRemotely(Message msg)
		{
			if (MessageReadRemotely != null)
				RaiseEvent(nameof(MessageReadRemotely), () => MessageReadRemotely(this, new MessageEventArgs(msg)));
		}