Compare commits
3 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfd2dc4fc6 | ||
|
|
5dc16a2880 | ||
|
|
b21b1f87b8 |
79 changed files with 75 additions and 2450 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,7 +3,6 @@
|
||||||
##
|
##
|
||||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
config.json
|
config.json
|
||||||
launchSettings.json
|
|
||||||
|
|
||||||
# User-specific files
|
# User-specific files
|
||||||
*.rsuser
|
*.rsuser
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,18 @@
|
||||||
using DSharpPlus;
|
using DSharpPlus;
|
||||||
using DSharpPlus.CommandsNext;
|
using DSharpPlus.CommandsNext;
|
||||||
using DSharpPlus.EventArgs;
|
using DSharpPlus.EventArgs;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Bot_Discord_CSharp.Dto;
|
||||||
using Bot_Discord_CSharp.Commands;
|
using Bot_Discord_CSharp.Commands;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using DSharpPlus.Interactivity;
|
using DSharpPlus.Interactivity;
|
||||||
using DSharpPlus.Interactivity.Extensions;
|
using DSharpPlus.Interactivity.Extensions;
|
||||||
using DSharpPlus.Entities;
|
using DSharpPlus.Entities;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Bot_Discord_CSharp.Dto;
|
|
||||||
|
|
||||||
namespace Bot_Discord_CSharp
|
namespace Bot_Discord_CSharp
|
||||||
{
|
{
|
||||||
|
|
@ -23,16 +25,22 @@ namespace Bot_Discord_CSharp
|
||||||
public async Task RunAsync()
|
public async Task RunAsync()
|
||||||
{
|
{
|
||||||
string token, prefix;
|
string token, prefix;
|
||||||
if (Environment.GetEnvironmentVariable("TOKEN") != null)
|
if (!Environment.GetEnvironmentVariables().Contains("TOKEN"))
|
||||||
|
{
|
||||||
|
var json = string.Empty;
|
||||||
|
|
||||||
|
using (var fs = File.OpenRead(@"E:\Proyectos Visual Studio\Bot_Discord_CSharp\Bot_Discord_CSharp\config.json"))
|
||||||
|
using (var sr = new StreamReader(fs, new UTF8Encoding(false)))
|
||||||
|
json = await sr.ReadToEndAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
|
var configJson = JsonConvert.DeserializeObject<ConfigDto>(json);
|
||||||
|
token = configJson.Token;
|
||||||
|
prefix = configJson.Prefix;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
token = Environment.GetEnvironmentVariable("TOKEN");
|
token = Environment.GetEnvironmentVariable("TOKEN");
|
||||||
prefix = Environment.GetEnvironmentVariable("PREFIX");
|
prefix = Environment.GetEnvironmentVariable("PREFIX");
|
||||||
} else
|
|
||||||
{
|
|
||||||
ProfilesDto profiles = JsonConvert.DeserializeObject<ProfilesDto>(System.IO.File.ReadAllText("./launchSettings.json"));
|
|
||||||
SecretsDto secrets = profiles.Bot_Discord_CSharp.EnvironmentVariables.Secrets;
|
|
||||||
token = secrets.Token;
|
|
||||||
prefix = secrets.Prefix;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = new DiscordConfiguration
|
var config = new DiscordConfiguration
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,19 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
|
|
||||||
<StartupObject>Bot_Discord_CSharp.Program</StartupObject>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DSharpPlus" Version="4.0.0-rc1" />
|
<PackageReference Include="DSharpPlus" Version="4.0.0-nightly-00760" />
|
||||||
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.0.0-rc1" />
|
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.0.0-nightly-00760" />
|
||||||
<PackageReference Include="DSharpPlus.Interactivity" Version="4.0.0-rc1" />
|
<PackageReference Include="DSharpPlus.Interactivity" Version="4.0.0-nightly-00760" />
|
||||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.28" />
|
<PackageReference Include="HtmlAgilityPack" Version="1.11.28" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ProjectExtensions><VisualStudio><UserProperties config_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
|
||||||
<Folder Include="Properties\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="Properties\launchSettings.json">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy csproj and restore as distinct layers
|
|
||||||
COPY *.sln .
|
|
||||||
COPY Bot_Discord_CSharp/*.csproj ./aspnetapp/
|
|
||||||
#COPY *.csproj ./
|
|
||||||
RUN dotnet restore
|
|
||||||
|
|
||||||
# Copy everything else and build
|
|
||||||
COPY Bot_Discord_CSharp/. ./aspnetapp/
|
|
||||||
WORKDIR /app/aspnetapp
|
|
||||||
#COPY . ./
|
|
||||||
RUN dotnet publish -c Release -o out
|
|
||||||
|
|
||||||
# Build runtime image
|
|
||||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 as runtime
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=build /app/aspnetapp/out ./
|
|
||||||
#COPY --from=build-env /app/out .
|
|
||||||
|
|
||||||
|
|
||||||
#COPY config.json ./
|
|
||||||
COPY Properties/launchSettings.json ./
|
|
||||||
|
|
||||||
ENTRYPOINT ["dotnet", "Bot_Discord_CSharp.dll"]
|
|
||||||
18
Bot_Discord_CSharp/Dockerfile.txt
Normal file
18
Bot_Discord_CSharp/Dockerfile.txt
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy csproj and restore as distinct layers
|
||||||
|
COPY *.csproj ./
|
||||||
|
RUN dotnet restore
|
||||||
|
|
||||||
|
# Copy everything else and build
|
||||||
|
COPY . ./
|
||||||
|
RUN dotnet publish -c Release -o out
|
||||||
|
|
||||||
|
# Build runtime image
|
||||||
|
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build-env /app/out .
|
||||||
|
|
||||||
|
#COPY config.json ./
|
||||||
|
ENTRYPOINT ["dotnet", "Bot_Discord_CSharp.dll"]
|
||||||
|
|
@ -5,29 +5,11 @@ using System.Text;
|
||||||
|
|
||||||
namespace Bot_Discord_CSharp.Dto
|
namespace Bot_Discord_CSharp.Dto
|
||||||
{
|
{
|
||||||
class ProfilesDto
|
class ConfigDto
|
||||||
{
|
{
|
||||||
[JsonProperty("profiles")]
|
[JsonProperty("token")]
|
||||||
public Bot_Discord_CSharpDto Bot_Discord_CSharp { get; private set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
class Bot_Discord_CSharpDto
|
|
||||||
{
|
|
||||||
[JsonProperty("Bot_Discord_CSharp")]
|
|
||||||
public EnvironmentVariablesDto EnvironmentVariables { get; private set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
class EnvironmentVariablesDto
|
|
||||||
{
|
|
||||||
[JsonProperty("environmentVariables")]
|
|
||||||
public SecretsDto Secrets { get; private set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
class SecretsDto
|
|
||||||
{
|
|
||||||
[JsonProperty("TOKEN")]
|
|
||||||
public string Token { get; private set; }
|
public string Token { get; private set; }
|
||||||
[JsonProperty("PREFIX")]
|
[JsonProperty("Prefix")]
|
||||||
public string Prefix { get; private set; }
|
public string Prefix { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
heroku container:login
|
|
||||||
docker build -t discord-bot-dsharp "E:\Proyectos Visual Studio\Bot_Discord_CSharp\Bot_Discord_CSharp\bin\Release\netcoreapp3.1\publish"
|
|
||||||
docker tag discord-bot-dsharp registry.heroku.com/discord-bot-dsharp/worker
|
|
||||||
docker push registry.heroku.com/discord-bot-dsharp/worker
|
|
||||||
heroku container:release worker --app discord-bot-dsharp
|
|
||||||
heroku container:push release --app discord-bot-dsharp
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
namespace Bot_Discord_CSharp
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace Bot_Discord_CSharp
|
||||||
{
|
{
|
||||||
public class Program
|
class Program
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Bot bot = new Bot();
|
Bot bot = new Bot();
|
||||||
bot.RunAsync().GetAwaiter().GetResult();
|
bot.RunAsync().GetAwaiter().GetResult();
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
version: "3"
|
version: "3"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
bot:
|
bot:
|
||||||
build: .
|
build: .
|
||||||
image: mydiscordbot
|
image: mydiscordbot
|
||||||
|
|
||||||
|
|
||||||
26
Dockerfile
26
Dockerfile
|
|
@ -1,26 +0,0 @@
|
||||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy csproj and restore as distinct layers
|
|
||||||
COPY *.sln .
|
|
||||||
COPY Bot_Discord_CSharp/*.csproj ./aspnetapp/
|
|
||||||
#COPY *.csproj ./
|
|
||||||
RUN dotnet restore
|
|
||||||
|
|
||||||
# Copy everything else and build
|
|
||||||
COPY Bot_Discord_CSharp/. ./aspnetapp/
|
|
||||||
WORKDIR /app/aspnetapp
|
|
||||||
#COPY . ./
|
|
||||||
RUN dotnet publish -c Release -o out
|
|
||||||
|
|
||||||
# Build runtime image
|
|
||||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 as runtime
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=build /app/aspnetapp/out ./
|
|
||||||
#COPY --from=build-env /app/out .
|
|
||||||
|
|
||||||
|
|
||||||
#COPY config.json ./
|
|
||||||
COPY Properties/launchSettings.json ./
|
|
||||||
|
|
||||||
ENTRYPOINT ["dotnet", "Bot_Discord_CSharp.dll"]
|
|
||||||
File diff suppressed because it is too large
Load diff
Binary file not shown.
Binary file not shown.
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"runtimeOptions": {
|
|
||||||
"tfm": "netcoreapp3.1",
|
|
||||||
"framework": {
|
|
||||||
"name": "Microsoft.NETCore.App",
|
|
||||||
"version": "3.1.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,28 +0,0 @@
|
||||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy csproj and restore as distinct layers
|
|
||||||
COPY *.sln .
|
|
||||||
WORKDIR /.
|
|
||||||
COPY Bot_Discord_CSharp/*.csproj ./aspnetapp/
|
|
||||||
WORKDIR /app
|
|
||||||
#COPY *.csproj ./
|
|
||||||
RUN dotnet restore
|
|
||||||
|
|
||||||
# Copy everything else and build
|
|
||||||
COPY Bot_Discord_CSharp/. ./aspnetapp/
|
|
||||||
WORKDIR /app/aspnetapp
|
|
||||||
#COPY . ./
|
|
||||||
RUN dotnet publish -c Release -o out
|
|
||||||
|
|
||||||
# Build runtime image
|
|
||||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 as runtime
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=build /app/aspnetapp/out ./
|
|
||||||
#COPY --from=build-env /app/out .
|
|
||||||
|
|
||||||
|
|
||||||
#COPY config.json ./
|
|
||||||
COPY Properties/launchSettings.json ./
|
|
||||||
|
|
||||||
ENTRYPOINT ["dotnet", "Bot_Discord_CSharp.dll"]
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,8 +0,0 @@
|
||||||
version: "3"
|
|
||||||
|
|
||||||
services:
|
|
||||||
bot:
|
|
||||||
build: .
|
|
||||||
image: mydiscordbot
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
22
azure-pipelines.yml
Normal file
22
azure-pipelines.yml
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# ASP.NET Core
|
||||||
|
# Build and test ASP.NET Core projects targeting .NET Core.
|
||||||
|
# Add steps that run tests, create a NuGet package, deploy, and more:
|
||||||
|
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
- main
|
||||||
|
pool:
|
||||||
|
vmImage: 'ubuntu-latest'
|
||||||
|
|
||||||
|
variables:
|
||||||
|
buildConfiguration: 'Release'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- script: dotnet build --configuration $(buildConfiguration)
|
||||||
|
displayName: 'dotnet build $(buildConfiguration)'
|
||||||
|
|
||||||
|
- task: DotNetCoreCLI@2
|
||||||
|
inputs:
|
||||||
|
command: 'publish'
|
||||||
|
publishWebProjects: false
|
||||||
|
projects: '**/*.csproj'
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
version: "3"
|
|
||||||
|
|
||||||
services:
|
|
||||||
bot:
|
|
||||||
build: .
|
|
||||||
image: mydiscordbot
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue