public async Task BanIp(CommandContext ctx, [RemainingText] string ipAddress)
        {
            await ctx.TriggerTypingAsync();

            Network.RegisterInvalidLogin(ipAddress);
            await ctx.RespondAsync(embed : EmbedTemplates.CreateSuccessEmbed("Added invalid login for IP " + ipAddress));
        }
Ejemplo n.º 2
0
        public async Task LinkServiceTask(CommandContext ctx)
        {
            var user = await AccountsService.GetUser(ctx);

            var service = await DiscordService.LinkService(ctx, user);

            await ctx.RespondAsync(embed : EmbedTemplates.CreateSuccessEmbed(service.Name, "Link Successful!"));
        }
Ejemplo n.º 3
0
        public Task LogoutUser(CommandContext ctx, DiscordMember discordMember)
        {
            var user = AccountsService.GetUser(discordMember.Id);

            AccountsService.LogoutUser(user, discordMember.Id);
            return(ctx.RespondAsync(
                       embed: EmbedTemplates.CreateSuccessEmbed(
                           description: $"**{user.FullName} has been unlinked and logged out.")));
        }
Ejemplo n.º 4
0
        public override async Task DoAction()
        {
            await base.DoAction();

            var service = Authentication.Service;

            service.Start("Started by Nexus.");
            var embed = EmbedTemplates.CreateSuccessEmbed($"{service.NameNoHtml}", "**Started successfully**");
            await CommandContext.RespondAsync(embed : embed);
        }
        public async Task GetVariable(CommandContext ctx, int userId, string variableName)
        {
            await ctx.TriggerTypingAsync();

            var user            = new User(userId);
            var userCustomField = user.CustomFields[variableName];

            await ctx.RespondAsync(embed : EmbedTemplates.CreateSuccessEmbed($"GetVariable for {user.UserName}",
                                                                             $"VariableName `{variableName}` value is {userCustomField}"));
        }
Ejemplo n.º 6
0
        public Task LogoutUser(CommandContext ctx, string username)
        {
            var user = User.GetUserByUserName(username);

            user.AppData.RemoveValue("OAUTH::Discord");
            user.Save();
            return(ctx.RespondAsync(
                       embed: EmbedTemplates.CreateSuccessEmbed(
                           description: $"**{user.FullName} has been unlinked and logged out.")));
        }
Ejemplo n.º 7
0
        public async Task UnlinkServices(CommandContext ctx)
        {
            var msg = await ctx.RespondAsync(embed : EmbedTemplates.CreateInfoEmbed("Unlink Services",
                                                                                    "Unlinking all services. Please wait..."));

            DiscordService.ResetAllServices(ctx);
            await msg.ModifyAsync(
                embed : new Optional <DiscordEmbed>(
                    EmbedTemplates.CreateSuccessEmbed(description: "Unlinked all services.")));
        }
        public async Task SetVariable(CommandContext ctx, int userId, string variableName, string variableValue)
        {
            await ctx.TriggerTypingAsync();

            var user = new User(userId);

            user.CustomFields[variableName] = variableValue;
            user.Save();

            await ctx.RespondAsync(embed : EmbedTemplates.CreateSuccessEmbed($"SetVariable for {user.UserName}",
                                                                             $"VariableName `{variableName}` value set to {variableValue}"));
        }
Ejemplo n.º 9
0
        public override async System.Threading.Tasks.Task DoAction()
        {
            await base.DoAction();

            var service = Authentication.Service;

            service.Stop("Stopped by Nexus.");
            // await CommandContext.RespondAsync($"**{service.NameNoHtml} has been stopped**");

            var embed = EmbedTemplates.CreateSuccessEmbed($"{service.NameNoHtml}", "**Stopped successfully**");
            await CommandContext.RespondAsync(embed : embed);
        }
Ejemplo n.º 10
0
        public async Task RestartMonitor(CommandContext ctx, string serverName)
        {
            if (!(Server.GetServers(true, serverName)[0] is Server server))
            {
                await ctx.RespondAsync(embed : EmbedTemplates.CreateErrorEmbed("Server Not Found",
                                                                               $"{serverName} could not be found."));

                return;
            }

            server.ServerUtilitiesService.RestartMonitor();
            await ctx.RespondAsync(embed : EmbedTemplates.CreateSuccessEmbed("Monitor Restart",
                                                                             $"{server.Name}'s monitor is restarting."));
        }
Ejemplo n.º 11
0
        public async Task ForceLinkService(CommandContext ctx, int serviceId)
        {
            await ctx.Message.DeleteAsync();

            if (DiscordService.LinkService(ctx.Guild.Id, serviceId))
            {
                await ctx.RespondAsync(embed : EmbedTemplates.CreateSuccessEmbed(description: "**Linked Service**"));
            }
            else
            {
                await ctx.RespondAsync(
                    embed : EmbedTemplates.CreateErrorEmbed(description: "**Failed to link service**"));
            }
        }
        public async Task SignOut(CommandContext ctx)
        {
            var user = AccountsService.GetUser(ctx.User.Id);

            if (user == null)
            {
                await ctx.RespondAsync(embed : EmbedTemplates.CreateErrorEmbed("Logout",
                                                                               "**You have to be signed in, in order to logout.**"));

                return;
            }

            AccountsService.LogoutUser(user, ctx.User.Id);
            await ctx.RespondAsync(embed : EmbedTemplates.CreateSuccessEmbed("Logout", "**You have been logged out**"));
        }
Ejemplo n.º 13
0
        public async Task LoginAs(CommandContext ctx, string username)
        {
            var user = User.GetUserByUserName(username);

            if (!user.Find())
            {
                await ctx.RespondAsync(embed : EmbedTemplates.CreateErrorEmbed("Login As", "Cannot find user"));

                return;
            }

            AccountsService.AddUserToEmulation(ctx.User.Id, user);
            await ctx.RespondAsync(
                embed : EmbedTemplates.CreateSuccessEmbed(description: "Logged in as " + user.UserName));
        }
Ejemplo n.º 14
0
        public async Task EmulateAs(CommandContext ctx, DiscordMember member)
        {
            var user = AccountsService.GetUser(member.Id);

            if (user == null || !user.Find())
            {
                await ctx.RespondAsync(embed : EmbedTemplates.CreateErrorEmbed(description: "User not found"));

                return;
            }

            AccountsService.AddUserToEmulation(ctx.User.Id, user);

            await ctx.RespondAsync(embed : EmbedTemplates.CreateSuccessEmbed(
                                       description: $"You are now emulating as: {member.Username}#{member.Discriminator} ({user.UserName})"));
        }
Ejemplo n.º 15
0
        public async Task DownloadFile(FileInfo file)
        {
            var server            = new Server(Service.ServerId);
            var directorySecurity = new TCAdmin.SDK.VirtualFileSystem.VirtualDirectorySecurity
            {
                Permissions        = Permission.Read | Permission.Write | Permission.Delete,
                PermissionType     = PermissionType.Root,
                RelativeExecutable =
                    Strings.ReplaceCaseInsensitive(Service.Executable, Service.RootDirectory, string.Empty),
                VirtualDirectoryName = Service.ConnectionInfo,
                RootPhysicalPath     = Service.RootDirectory,
                RealPhysicalPath     =
                    TCAdmin.SDK.Misc.FileSystem.FixAbsoluteFilePath(Service.RootDirectory, server.OperatingSystem),
                ServerId = server.ServerId
            };
            var download = new RemoteDownload(server)
            {
                DirectorySecurity = directorySecurity,
                FileName          = file.FullName
            };

            if (file.Length / 1024 > 8)
            {
                await CommandContext.RespondAsync(
                    embed : EmbedTemplates.CreateSuccessEmbed(
                        $"[<{download.GetDownloadUrl()}>](**Click here to download {file.Name}**)"));
            }
            else
            {
                using (var client = new WebClient())
                {
                    client.DownloadFileCompleted += delegate { CommandContext.RespondWithFileAsync(file.Name); };

                    client.DownloadFileAsync(new Uri(download.GetDownloadUrl()), file.Name);
                }
            }

            await Task.Delay(3000);

            File.Delete(file.Name);
        }
Ejemplo n.º 16
0
        public Task EmulateAs(CommandContext ctx)
        {
            AccountsService.RemoveUserFromEmulation(ctx.User.Id);

            return(ctx.RespondAsync(embed: EmbedTemplates.CreateSuccessEmbed(description: "Emulation Stopped")));
        }