Example #1
0
        public override Task UserTextMessage(Murmur.User user, Murmur.TextMessage message)
        {
            var apiUser   = new UserWrapper(SteamListener, WServer, user);
            var destChans = message.channels.Select(x => new ChannelShim(WServer, x)).ToArray();

            return(Task.WhenAll(Plugins.Select(x => x.OnChatMessage(apiUser, destChans, message.text))));
        }
Example #2
0
        public override async Task UserTextMessage(Murmur.User user, Murmur.TextMessage message)
        {
            using (var context = await FancyContext.Connect())
                using (var transact = context.Database.BeginTransaction())
                {
                    User senderEntity = null;
                    if (user.userid > 0)
                    {
                        senderEntity = await context.Users.FindAsync(user.userid);
                    }

                    var qtext = message.text.Replace(""", "\"");
                    var msg   = CommandPattern.Matches(qtext).Cast <Match>().Select(m => m.Value).ToArray();
                    if (message.channels.Any())
                    {
                        if (msg[0] == "@fancy-ng")
                        {
                            await CommandMgr.HandleCommand(SteamListener, Server, user, msg.Skip(1));
                        }

                        if (senderEntity != null)
                        {
                            context.Logs.Add(new LogEntry.ChatMessage
                            {
                                When    = DateTimeOffset.Now,
                                Who     = senderEntity,
                                Where   = await context.Channels.SingleAsync(x => x.ServerId == user.channel),
                                Message = message.text
                            });
                        }
                    }

                    if (senderEntity != null)
                    {
                        var messagesInTheLastSeconds = await context.Logs.OfType <LogEntry.ChatMessage>()
                                                       .Where(x => x.Who.Id == senderEntity.Id && x.When > DbFunctions.AddSeconds(DateTimeOffset.Now, -5)).CountAsync();

                        if (messagesInTheLastSeconds >= 3)
                        {
                            await Server.KickUser(user.session, "Who are you, my evil twin?! [stop spamming]");
                        }
                    }

                    await context.SaveChangesAsync();

                    transact.Commit();
                }
        }
Example #3
0
 public sealed override void userTextMessage_async(Murmur.AMD_ServerCallback_userTextMessage cb__, Murmur.User state, Murmur.TextMessage message, Ice.Current current__)
 {
     cb__.ice_response();
     AsyncCompleter(UserTextMessage(state, message));
 }
Example #4
0
 public virtual Task UserTextMessage(Murmur.User user, Murmur.TextMessage message)
 {
     return(NullTask);
 }