Example #1
0
        private async Task ProcessOnChannelMessageReceived(object sender, IrcMessageEventArgs eventArgs)
        {
            IrcChannel channel = sender as IrcChannel;

            var logMessage = $"{channel?.Name} Received Message '{eventArgs.Text}' from '{eventArgs.Source.Name}'";

            if (channel is not null)
            {
                logMessage += $" in channel '{channel.Name}'";
            }

            _logger.Log(LogLevel.Debug, logMessage);

            var channeluser = channel.GetChannelUser(eventArgs.Source as IrcUser);

            if (eventArgs.Source.Name == _userInfo.NickName)
            {
                return;
            }

            var ctx = new IrcCommandContext(_client, eventArgs.Source.Name, channeluser.User, eventArgs.Text, "!", _services, channel);
            await _commandHandler.MessageRecivedAsync(ctx, eventArgs.Text);

            await _relay.IRC_MessageReceived(channel.Name, eventArgs.Source.Name, eventArgs.Text);
        }
Example #2
0
        public void ExecuteIrcCommand(IrcCommandContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            IIrcCommand command = _ircCommands.First(ic => ic.Name == context.Command);

            command.SetContext(context);
            if (command.NeedsOperPermission && context.MessageOrigin != MessageOrigin.Quartz)
            {
                var isOper = command.CheckPermissions();
                if (!isOper)
                {
                    return;
                }
            }
            else
            {
                //suppose people might "guess" the oper notice commands, silent ignore
                if (context.MessageOrigin != MessageOrigin.Notice & context.MessageOrigin != MessageOrigin.Quartz)
                {
                    return;
                }
            }
            command.MapInput();
            if (command.CheckPreconditions())
            {
                command.Execute();
            }
            _userDao.Persist();
            command.Write();
        }
Example #3
0
        private async Task HandleOnPrivateMessage(object receiver, IrcMessageEventArgs eventArgs)
        {
            IrcUser user = eventArgs.Source as IrcUser;

            var ctx = new IrcCommandContext(_client, eventArgs.Source.Name, user, eventArgs.Text, "!", _services);

            await _commandHandler.MessageRecivedAsync(ctx, eventArgs.Text);
        }
Example #4
0
        public void Execute(IJobExecutionContext context)
        {
            var commandContext = new IrcCommandContext {
                Command = CommandName.IrcSecuritySweep, MessageOrigin = MessageOrigin.Quartz
            };

            _ircCommands.ExecuteIrcCommand(commandContext);
        }
 public void SetContext(IrcCommandContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     Context = context;
 }
Example #6
0
        public override async Task ReplyAsync(IrcCommandContext ctx, TwitchStreamsResult data)
        {
            List <string> res = new();

            foreach (var s in data.Streams)
            {
                res.Add($"{s.UserLogin}: {s.StreamLink}");
            }

            await ctx.ReplyAsync($"Live Streams: {string.Join(" | ", res)}");
        }
Example #7
0
        public static IrcUserCapsule?GetIrcUserCapsule(Parameter p, string v, IrcCommandContext ctx)
        {
            var users = ctx.LocalUser.GetChannelUsers();

            var user = users.FirstOrDefault(x => x.User.NickName == v);

            if (user is not null)
            {
                return(new IrcUserCapsule(user.User));
            }

            return(null);
        }
Example #8
0
        public override async Task ReplyAsync(IrcCommandContext ctx, FetchClanResult data)
        {
            string res = $"Clan: {data.Clan.Name} ({data.Clan.URL}), Size: {data.Clan.Size}, Description: {data.Clan.Description?.Replace("\n", " ")}";

            await ctx.ReplyAsync(res);
        }
Example #9
0
 public override async Task ReplyAsync(IrcCommandContext ctx, UnitDatabaseSerachResult data)
 {
     var desc = data.GeneralData.UnitName is not null ? $@"""{data.GeneralData.UnitName}"" {data.Description}" : data.Description;
     await ctx.ReplyAsync($"[{data.GeneralData.FactionName} - {data.Id}] {desc}: {data.GetUnitDatabaseUrl()}");
 }
Example #10
0
 public virtual Task ReplyAsync(IrcCommandContext ctx, T data) => ctx.ReplyAsync(data?.ToString() ?? "No Data");
Example #11
0
 public override async Task ReplyAsync(IrcCommandContext ctx, MapResult data)
 => await ctx.ReplyAsync($"Map: {data.Title}, ID: {data.Id}, Size: {data.Size}," +
                         $" Players: {data.MaxPlayers}, Ranked: {data.Ranked}, Author: {data.Author}," +
                         $" Download: {data.DownloadUrl?.AbsoluteUri.Replace(" ", "%20")}," +
                         $" Preview: {data.PreviewUrl?.AbsoluteUri.Replace(" ", "%20")}");
Example #12
0
 public override Task ReplyAsync(IrcCommandContext ctx, FetchPlayerStatsResult data)
 {
     return(Context.ReplyAsync($"found player '{data.Name}' with the following information:\n" +
                               $"1v1: rating '{data.LadderStats?.Rating.ToString("F0") ?? "0"}', ranked '{data.LadderStats?.Ranking ?? 0}'\n" +
                               $"Global: rating '{data.GlobalStats?.Rating.ToString("F0") ?? "0"}', ranked '{data.GlobalStats?.Ranking ?? 0}'"));
 }