Ejemplo n.º 1
0
 public void OnPrivateMessageEvent(BanchoSendIrcMessageArgs args)
 {
     if (args.Pr == BotPresence)
     {
         return;
     }
 }
Ejemplo n.º 2
0
        public void OnPrivateMessage(BanchoSendIrcMessageArgs args)
        {
            if (!_ps.TryGet(args.Message.ChannelTarget, out var target))
            {
                args.Pr.Push(new Announce("This User is Offline!"));
                return;
            }

            Logger.Info(
                $"{LCol.RED}{args.Pr.User.UserName}",
                $"{LCol.PURPLE}( {args.Pr.User.Id} )",
                $"{LCol.YELLOW}(Private Message)",
                $"{LCol.WHITE}=>",
                $"{LCol.RED}{args.Pr.User.UserName}",
                $"{LCol.PURPLE}( {args.Pr.User.Id} )"
                );

            var newMsg = new MessageStruct
            {
                Username      = args.Pr.User.UserName,
                Message       = _filter.Filter(args.Message.Message),
                ChannelTarget = args.Pr.User.UserName,
                SenderId      = args.Pr.User.Id,
            };

            target.Push(new SendIrcMessage(newMsg));
        }
Ejemplo n.º 3
0
        public void OnPublicMessage(BanchoSendIrcMessageArgs args)
        {
            Channel channel;

            switch (args.Message.ChannelTarget)
            {
            case "#spectator":
                channel = args.Pr.Spectator?.Channel;
                break;

            case "#multiplayer":
                channel = args.Pr.ActiveMatch?.Channel;
                break;

            default:
                _cs.TryGet(args.Message.ChannelTarget, out channel);
                break;
            }

            if (channel == null)
            {
                args.Pr.Push(new ChannelRevoked(args.Message.ChannelTarget));
                return;
            }

            Logger.Info(
                $"{LCol.RED}{args.Pr.User.UserName}",
                $"{LCol.PURPLE}( {args.Pr.User.Id} )",
                $"{LCol.YELLOW}{args.Message.Message}",
                $"{LCol.WHITE}=>",
                $"{LCol.RED}{channel.Name}"
                );

            args.Message.Username = args.Pr.User.UserName;
            args.Message.Message  = _filter.Filter(args.Message.Message);

            channel.Push(new SendIrcMessage(args.Message), args.Pr);
        }
Ejemplo n.º 4
0
        public void OnPublicMessageEvent(BanchoSendIrcMessageArgs args)
        {
            if (args.Pr == BotPresence)
            {
                return;
            }

            if (!args.Message.Message.StartsWith("!"))
            {
                return;
            }

            if (!_cs.TryGet(args.Message.ChannelTarget, out var _))
            {
                return;
            }

            var cmds = GetCommands(args.Message.Message.TrimStart('!'));

            foreach (var cmd in cmds)
            {
                if (args.Pr.User.Permissions != cmd.RequiredPermission)
                {
                    continue;
                }

                var l = args.Message.Message.TrimStart('!').Split(" ").ToList();
                l.RemoveAt(0);
                if (l.Count < cmd.ExpectedArgs)
                {
                    var aList = "\t<";

                    var i = 0;
                    foreach (var a in cmd.Args)
                    {
                        aList += a.ArgName;
                        if (i >= cmd.ExpectedArgs)
                        {
                            aList += "?";
                        }
                        aList += ", ";
                        i++;
                    }

                    aList = aList.TrimEnd(cmd.Args.Count < 1 ? '<' : ' ').TrimEnd(',');
                    if (cmd.Args.Count > 0)
                    {
                        aList += ">";
                    }

                    SendMessage(
                        $"Insufficient amount of Arguments!\nUsage:\n     !{cmd.Command} {aList}",
                        args.Message.ChannelTarget, false
                        );
                    break;
                }

                if (cmd.Callback(args.Pr, l.ToArray()))
                {
                    break;
                }
            }
        }