commit 62c9e6165e03d32efb2d24b960e428a54a944b08 Author: Nikita Arinkin Date: Thu Feb 4 00:40:23 2021 +0300 Release test versions of telegram bot and AutomatizationCore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..72a95c8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +bin/ +obj/ +/packages/ +/.idea/ +/.vs/ \ No newline at end of file diff --git a/AutomatizationCore/.dockerignore b/AutomatizationCore/.dockerignore new file mode 100644 index 0000000..3729ff0 --- /dev/null +++ b/AutomatizationCore/.dockerignore @@ -0,0 +1,25 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md \ No newline at end of file diff --git a/AutomatizationCore/AutomatizationCore.sln b/AutomatizationCore/AutomatizationCore.sln new file mode 100644 index 0000000..0e0ec22 --- /dev/null +++ b/AutomatizationCore/AutomatizationCore.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomatizationCoreApp", "AutomatizationCoreApp\AutomatizationCoreApp.csproj", "{CCAA54A5-055D-4D0D-95CE-0F736502D937}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CCAA54A5-055D-4D0D-95CE-0F736502D937}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CCAA54A5-055D-4D0D-95CE-0F736502D937}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CCAA54A5-055D-4D0D-95CE-0F736502D937}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CCAA54A5-055D-4D0D-95CE-0F736502D937}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/AutomatizationCore/AutomatizationCoreApp/AutomatizationCoreApp.csproj b/AutomatizationCore/AutomatizationCoreApp/AutomatizationCoreApp.csproj new file mode 100644 index 0000000..c7b0507 --- /dev/null +++ b/AutomatizationCore/AutomatizationCoreApp/AutomatizationCoreApp.csproj @@ -0,0 +1,19 @@ + + + + net5.0 + a9a11b76-8ac6-4b47-9599-dc45586a5f3d + Linux + + + + + + + + + + + + + diff --git a/AutomatizationCore/AutomatizationCoreApp/Dockerfile b/AutomatizationCore/AutomatizationCoreApp/Dockerfile new file mode 100644 index 0000000..90e7c5e --- /dev/null +++ b/AutomatizationCore/AutomatizationCoreApp/Dockerfile @@ -0,0 +1,22 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build +WORKDIR /src +COPY ["AutomatizationCoreApp/AutomatizationCoreApp.csproj", "AutomatizationCoreApp/"] +RUN dotnet restore "AutomatizationCoreApp/AutomatizationCoreApp.csproj" +COPY . . +WORKDIR "/src/AutomatizationCoreApp" +RUN dotnet build "AutomatizationCoreApp.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "AutomatizationCoreApp.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "AutomatizationCoreApp.dll"] \ No newline at end of file diff --git a/AutomatizationCore/AutomatizationCoreApp/Program.cs b/AutomatizationCore/AutomatizationCoreApp/Program.cs new file mode 100644 index 0000000..25dbae9 --- /dev/null +++ b/AutomatizationCore/AutomatizationCoreApp/Program.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace AutomatizationCoreApp +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + // Additional configuration is required to successfully run gRPC on macOS. + // For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682 + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }); + } +} \ No newline at end of file diff --git a/AutomatizationCore/AutomatizationCoreApp/Properties/launchSettings.json b/AutomatizationCore/AutomatizationCoreApp/Properties/launchSettings.json new file mode 100644 index 0000000..6a3a5fc --- /dev/null +++ b/AutomatizationCore/AutomatizationCoreApp/Properties/launchSettings.json @@ -0,0 +1,18 @@ +{ + "profiles": { + "AutomatizationCoreApp": { + "commandName": "Project", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": "true", + "applicationUrl": "http://localhost:5000;https://localhost:5001" + }, + "Docker": { + "commandName": "Docker", + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "publishAllPorts": true, + "useSSL": true + } + } +} \ No newline at end of file diff --git a/AutomatizationCore/AutomatizationCoreApp/Services/AutomatizatorService.cs b/AutomatizationCore/AutomatizationCoreApp/Services/AutomatizatorService.cs new file mode 100644 index 0000000..bb11299 --- /dev/null +++ b/AutomatizationCore/AutomatizationCoreApp/Services/AutomatizatorService.cs @@ -0,0 +1,23 @@ +using Grpc.Core; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace AutomatizationCoreApp.Services +{ + public class AutomatizatorService : Automatizator.AutomatizatorBase + { + public override Task AddRequest(RequestInfo request, ServerCallContext context) + { + Console.WriteLine("Get add request"); + return Task.FromResult(new OperationResult(){ Message = "Test" }); + } + + public override Task GetUserRequests(UserInfo request, ServerCallContext context) + { + Console.WriteLine("Get user requests"); + return base.GetUserRequests(request, context); + } + } +} diff --git a/AutomatizationCore/AutomatizationCoreApp/Startup.cs b/AutomatizationCore/AutomatizationCoreApp/Startup.cs new file mode 100644 index 0000000..75e02e6 --- /dev/null +++ b/AutomatizationCore/AutomatizationCoreApp/Startup.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using AutomatizationCoreApp.Services; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace AutomatizationCoreApp +{ + public class Startup + { + // This method gets called by the runtime. Use this method to add services to the container. + // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 + public void ConfigureServices(IServiceCollection services) + { + services.AddGrpc(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseRouting(); + + app.UseEndpoints(endpoints => + { + endpoints.MapGrpcService(); + + endpoints.MapGet("/", + async context => + { + await context.Response.WriteAsync( + "Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909"); + }); + }); + } + } +} \ No newline at end of file diff --git a/AutomatizationCore/AutomatizationCoreApp/appsettings.Development.json b/AutomatizationCore/AutomatizationCoreApp/appsettings.Development.json new file mode 100644 index 0000000..fe20c40 --- /dev/null +++ b/AutomatizationCore/AutomatizationCoreApp/appsettings.Development.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Grpc": "Information", + "Microsoft": "Information" + } + } +} diff --git a/AutomatizationCore/AutomatizationCoreApp/appsettings.json b/AutomatizationCore/AutomatizationCoreApp/appsettings.json new file mode 100644 index 0000000..1f29241 --- /dev/null +++ b/AutomatizationCore/AutomatizationCoreApp/appsettings.json @@ -0,0 +1,15 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*", + "Kestrel": { + "EndpointDefaults": { + "Protocols": "Http2" + } + } +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..79439d7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: "3" + +services: + telegram-bot: + container_name: telegram-bot + networks: + - automatization_network + + redis: + image: redis + container_name: redis + volumes: + - ./redis-data:/data + command: + - redis-server --requirepass nikitos1 + networks: + - automatization_network + +networks: + automatization_network: \ No newline at end of file diff --git a/telegram-bot/Dockerfile b/telegram-bot/Dockerfile new file mode 100644 index 0000000..9f95a6e --- /dev/null +++ b/telegram-bot/Dockerfile @@ -0,0 +1,13 @@ +FROM golang:alpine as builder +WORKDIR /app +RUN apk update && apk upgrade && apk add --no-cache ca-certificates +RUN update-ca-certificates +ADD telegram-bot.go /app/ +ADD go.mod /app/ +ADD go.sum /app/ +RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags="-s -w" -installsuffix cgo -o app . + +FROM scratch +COPY --from=builder /app/app . +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +CMD ["./app"] \ No newline at end of file diff --git a/telegram-bot/go.mod b/telegram-bot/go.mod new file mode 100644 index 0000000..5c8d7df --- /dev/null +++ b/telegram-bot/go.mod @@ -0,0 +1,12 @@ +module nikozavr.ru/plexautomatization + +go 1.15 + +require ( + github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible + github.com/golang/protobuf v1.4.2 + github.com/technoweenie/multipartstreamer v1.0.1 // indirect + google.golang.org/grpc v1.35.0 + google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 // indirect + google.golang.org/protobuf v1.25.0 +) diff --git a/telegram-bot/go.sum b/telegram-bot/go.sum new file mode 100644 index 0000000..49b9f2b --- /dev/null +++ b/telegram-bot/go.sum @@ -0,0 +1,91 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/go-telegram-bot-api/telegram-bot-api v1.0.0 h1:HXVtsZ+yINQeyyhPFAUU4yKmeN+iFhJ87jXZOC016gs= +github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible h1:2cauKuaELYAEARXRkq2LrJ0yDDv1rW7+wrTEdVL3uaU= +github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible/go.mod h1:qf9acutJ8cwBUhm1bqgz6Bei9/C/c93FPDljKWwsOgM= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1 h1:ZFgWrT+bLgsYPirOnRfKLYJLvssAegOj/hgyMFdJZe0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM= +github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.35.0 h1:TwIQcH3es+MojMVojxxfQ3l3OF2KzlRxML2xZq0kRo8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 h1:M1YKkFIboKNieVO5DLUEVzQfGwJD30Nv2jfUgzb5UcE= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/telegram-bot/grpc/Automatization.pb.go b/telegram-bot/grpc/Automatization.pb.go new file mode 100644 index 0000000..2005def --- /dev/null +++ b/telegram-bot/grpc/Automatization.pb.go @@ -0,0 +1,521 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.13.0 +// source: Automatization.proto + +package grpc + +import ( + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type RequestStatus_Status int32 + +const ( + RequestStatus_ACCEPTED RequestStatus_Status = 0 + RequestStatus_DISLINED RequestStatus_Status = 1 + RequestStatus_DOWNLOADING RequestStatus_Status = 2 + RequestStatus_DOWNLOADED RequestStatus_Status = 3 + RequestStatus_ADDED RequestStatus_Status = 4 +) + +// Enum value maps for RequestStatus_Status. +var ( + RequestStatus_Status_name = map[int32]string{ + 0: "ACCEPTED", + 1: "DISLINED", + 2: "DOWNLOADING", + 3: "DOWNLOADED", + 4: "ADDED", + } + RequestStatus_Status_value = map[string]int32{ + "ACCEPTED": 0, + "DISLINED": 1, + "DOWNLOADING": 2, + "DOWNLOADED": 3, + "ADDED": 4, + } +) + +func (x RequestStatus_Status) Enum() *RequestStatus_Status { + p := new(RequestStatus_Status) + *p = x + return p +} + +func (x RequestStatus_Status) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (RequestStatus_Status) Descriptor() protoreflect.EnumDescriptor { + return file_Automatization_proto_enumTypes[0].Descriptor() +} + +func (RequestStatus_Status) Type() protoreflect.EnumType { + return &file_Automatization_proto_enumTypes[0] +} + +func (x RequestStatus_Status) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use RequestStatus_Status.Descriptor instead. +func (RequestStatus_Status) EnumDescriptor() ([]byte, []int) { + return file_Automatization_proto_rawDescGZIP(), []int{4, 0} +} + +type OperationResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *OperationResult) Reset() { + *x = OperationResult{} + if protoimpl.UnsafeEnabled { + mi := &file_Automatization_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OperationResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OperationResult) ProtoMessage() {} + +func (x *OperationResult) ProtoReflect() protoreflect.Message { + mi := &file_Automatization_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OperationResult.ProtoReflect.Descriptor instead. +func (*OperationResult) Descriptor() ([]byte, []int) { + return file_Automatization_proto_rawDescGZIP(), []int{0} +} + +func (x *OperationResult) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +func (x *OperationResult) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +type RequestInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserId int32 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + MediaName string `protobuf:"bytes,2,opt,name=media_name,json=mediaName,proto3" json:"media_name,omitempty"` +} + +func (x *RequestInfo) Reset() { + *x = RequestInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_Automatization_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequestInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequestInfo) ProtoMessage() {} + +func (x *RequestInfo) ProtoReflect() protoreflect.Message { + mi := &file_Automatization_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RequestInfo.ProtoReflect.Descriptor instead. +func (*RequestInfo) Descriptor() ([]byte, []int) { + return file_Automatization_proto_rawDescGZIP(), []int{1} +} + +func (x *RequestInfo) GetUserId() int32 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *RequestInfo) GetMediaName() string { + if x != nil { + return x.MediaName + } + return "" +} + +type UserInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserId int32 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` +} + +func (x *UserInfo) Reset() { + *x = UserInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_Automatization_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UserInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserInfo) ProtoMessage() {} + +func (x *UserInfo) ProtoReflect() protoreflect.Message { + mi := &file_Automatization_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserInfo.ProtoReflect.Descriptor instead. +func (*UserInfo) Descriptor() ([]byte, []int) { + return file_Automatization_proto_rawDescGZIP(), []int{2} +} + +func (x *UserInfo) GetUserId() int32 { + if x != nil { + return x.UserId + } + return 0 +} + +type RequestLists struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RequestStatuses []*RequestStatus `protobuf:"bytes,1,rep,name=request_statuses,json=requestStatuses,proto3" json:"request_statuses,omitempty"` +} + +func (x *RequestLists) Reset() { + *x = RequestLists{} + if protoimpl.UnsafeEnabled { + mi := &file_Automatization_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequestLists) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequestLists) ProtoMessage() {} + +func (x *RequestLists) ProtoReflect() protoreflect.Message { + mi := &file_Automatization_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RequestLists.ProtoReflect.Descriptor instead. +func (*RequestLists) Descriptor() ([]byte, []int) { + return file_Automatization_proto_rawDescGZIP(), []int{3} +} + +func (x *RequestLists) GetRequestStatuses() []*RequestStatus { + if x != nil { + return x.RequestStatuses + } + return nil +} + +type RequestStatus struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + MediaName string `protobuf:"bytes,1,opt,name=media_name,json=mediaName,proto3" json:"media_name,omitempty"` + Status RequestStatus_Status `protobuf:"varint,2,opt,name=status,proto3,enum=grpc.RequestStatus_Status" json:"status,omitempty"` + Info string `protobuf:"bytes,3,opt,name=info,proto3" json:"info,omitempty"` +} + +func (x *RequestStatus) Reset() { + *x = RequestStatus{} + if protoimpl.UnsafeEnabled { + mi := &file_Automatization_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequestStatus) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequestStatus) ProtoMessage() {} + +func (x *RequestStatus) ProtoReflect() protoreflect.Message { + mi := &file_Automatization_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RequestStatus.ProtoReflect.Descriptor instead. +func (*RequestStatus) Descriptor() ([]byte, []int) { + return file_Automatization_proto_rawDescGZIP(), []int{4} +} + +func (x *RequestStatus) GetMediaName() string { + if x != nil { + return x.MediaName + } + return "" +} + +func (x *RequestStatus) GetStatus() RequestStatus_Status { + if x != nil { + return x.Status + } + return RequestStatus_ACCEPTED +} + +func (x *RequestStatus) GetInfo() string { + if x != nil { + return x.Info + } + return "" +} + +var File_Automatization_proto protoreflect.FileDescriptor + +var file_Automatization_proto_rawDesc = []byte{ + 0x0a, 0x14, 0x41, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x67, 0x72, 0x70, 0x63, 0x22, 0x45, 0x0a, 0x0f, + 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, + 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x22, 0x45, 0x0a, 0x0b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x6e, + 0x66, 0x6f, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, + 0x65, 0x64, 0x69, 0x61, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x23, 0x0a, 0x08, 0x55, 0x73, + 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, + 0x4e, 0x0a, 0x0c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x73, 0x12, + 0x3e, 0x0a, 0x10, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x67, 0x72, 0x70, 0x63, + 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0f, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x65, 0x73, 0x22, + 0xc8, 0x01, 0x0a, 0x0d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x4e, 0x61, 0x6d, 0x65, + 0x12, 0x32, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x1a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x50, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x12, 0x0c, 0x0a, 0x08, 0x41, 0x43, 0x43, 0x45, 0x50, 0x54, 0x45, 0x44, 0x10, 0x00, + 0x12, 0x0c, 0x0a, 0x08, 0x44, 0x49, 0x53, 0x4c, 0x49, 0x4e, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0f, + 0x0a, 0x0b, 0x44, 0x4f, 0x57, 0x4e, 0x4c, 0x4f, 0x41, 0x44, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x12, + 0x0e, 0x0a, 0x0a, 0x44, 0x4f, 0x57, 0x4e, 0x4c, 0x4f, 0x41, 0x44, 0x45, 0x44, 0x10, 0x03, 0x12, + 0x09, 0x0a, 0x05, 0x41, 0x44, 0x44, 0x45, 0x44, 0x10, 0x04, 0x32, 0x7e, 0x0a, 0x0d, 0x41, 0x75, + 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x69, 0x7a, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x36, 0x0a, 0x0a, 0x41, + 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x11, 0x2e, 0x67, 0x72, 0x70, 0x63, + 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x15, 0x2e, 0x67, + 0x72, 0x70, 0x63, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x12, 0x35, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x0e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x55, 0x73, + 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x73, 0x42, 0x3d, 0x5a, 0x23, 0x6e, 0x69, + 0x6b, 0x6f, 0x7a, 0x61, 0x76, 0x72, 0x2e, 0x72, 0x75, 0x2f, 0x70, 0x6c, 0x65, 0x78, 0x61, 0x75, + 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x67, 0x72, 0x70, + 0x63, 0xaa, 0x02, 0x15, 0x41, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x69, 0x7a, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x43, 0x6f, 0x72, 0x65, 0x41, 0x70, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_Automatization_proto_rawDescOnce sync.Once + file_Automatization_proto_rawDescData = file_Automatization_proto_rawDesc +) + +func file_Automatization_proto_rawDescGZIP() []byte { + file_Automatization_proto_rawDescOnce.Do(func() { + file_Automatization_proto_rawDescData = protoimpl.X.CompressGZIP(file_Automatization_proto_rawDescData) + }) + return file_Automatization_proto_rawDescData +} + +var file_Automatization_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_Automatization_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_Automatization_proto_goTypes = []interface{}{ + (RequestStatus_Status)(0), // 0: grpc.RequestStatus.Status + (*OperationResult)(nil), // 1: grpc.OperationResult + (*RequestInfo)(nil), // 2: grpc.RequestInfo + (*UserInfo)(nil), // 3: grpc.UserInfo + (*RequestLists)(nil), // 4: grpc.RequestLists + (*RequestStatus)(nil), // 5: grpc.RequestStatus +} +var file_Automatization_proto_depIdxs = []int32{ + 5, // 0: grpc.RequestLists.request_statuses:type_name -> grpc.RequestStatus + 0, // 1: grpc.RequestStatus.status:type_name -> grpc.RequestStatus.Status + 2, // 2: grpc.Automatizator.AddRequest:input_type -> grpc.RequestInfo + 3, // 3: grpc.Automatizator.GetUserRequests:input_type -> grpc.UserInfo + 1, // 4: grpc.Automatizator.AddRequest:output_type -> grpc.OperationResult + 4, // 5: grpc.Automatizator.GetUserRequests:output_type -> grpc.RequestLists + 4, // [4:6] is the sub-list for method output_type + 2, // [2:4] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_Automatization_proto_init() } +func file_Automatization_proto_init() { + if File_Automatization_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_Automatization_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OperationResult); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Automatization_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequestInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Automatization_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UserInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Automatization_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequestLists); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Automatization_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequestStatus); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_Automatization_proto_rawDesc, + NumEnums: 1, + NumMessages: 5, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_Automatization_proto_goTypes, + DependencyIndexes: file_Automatization_proto_depIdxs, + EnumInfos: file_Automatization_proto_enumTypes, + MessageInfos: file_Automatization_proto_msgTypes, + }.Build() + File_Automatization_proto = out.File + file_Automatization_proto_rawDesc = nil + file_Automatization_proto_goTypes = nil + file_Automatization_proto_depIdxs = nil +} diff --git a/telegram-bot/grpc/Automatization.proto b/telegram-bot/grpc/Automatization.proto new file mode 100644 index 0000000..1377d72 --- /dev/null +++ b/telegram-bot/grpc/Automatization.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; + +option csharp_namespace = "AutomatizationCoreApp"; +option go_package = "nikozavr.ru/plexautomatization/grpc"; + +package grpc; + +service Automatizator { + rpc AddRequest(RequestInfo) returns (OperationResult); + + rpc GetUserRequests(UserInfo) returns (RequestLists); +} + +message OperationResult { + bool success = 1; + string message = 2; +} + +message RequestInfo { + int32 user_id = 1; + string media_name = 2; +} + +message UserInfo { + int32 user_id = 1; +} + +message RequestLists { + repeated RequestStatus request_statuses = 1; +} + +message RequestStatus { + enum Status { + ACCEPTED = 0; + DISLINED = 1; + DOWNLOADING = 2; + DOWNLOADED = 3; + ADDED = 4; + } + + string media_name = 1; + Status status = 2; + string info = 3; +} \ No newline at end of file diff --git a/telegram-bot/grpc/Automatization_grpc.pb.go b/telegram-bot/grpc/Automatization_grpc.pb.go new file mode 100644 index 0000000..ef88afe --- /dev/null +++ b/telegram-bot/grpc/Automatization_grpc.pb.go @@ -0,0 +1,137 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package grpc + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// AutomatizatorClient is the client API for Automatizator service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type AutomatizatorClient interface { + AddRequest(ctx context.Context, in *RequestInfo, opts ...grpc.CallOption) (*OperationResult, error) + GetUserRequests(ctx context.Context, in *UserInfo, opts ...grpc.CallOption) (*RequestLists, error) +} + +type automatizatorClient struct { + cc grpc.ClientConnInterface +} + +func NewAutomatizatorClient(cc grpc.ClientConnInterface) AutomatizatorClient { + return &automatizatorClient{cc} +} + +func (c *automatizatorClient) AddRequest(ctx context.Context, in *RequestInfo, opts ...grpc.CallOption) (*OperationResult, error) { + out := new(OperationResult) + err := c.cc.Invoke(ctx, "/grpc.Automatizator/AddRequest", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *automatizatorClient) GetUserRequests(ctx context.Context, in *UserInfo, opts ...grpc.CallOption) (*RequestLists, error) { + out := new(RequestLists) + err := c.cc.Invoke(ctx, "/grpc.Automatizator/GetUserRequests", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AutomatizatorServer is the server API for Automatizator service. +// All implementations must embed UnimplementedAutomatizatorServer +// for forward compatibility +type AutomatizatorServer interface { + AddRequest(context.Context, *RequestInfo) (*OperationResult, error) + GetUserRequests(context.Context, *UserInfo) (*RequestLists, error) + mustEmbedUnimplementedAutomatizatorServer() +} + +// UnimplementedAutomatizatorServer must be embedded to have forward compatible implementations. +type UnimplementedAutomatizatorServer struct { +} + +func (UnimplementedAutomatizatorServer) AddRequest(context.Context, *RequestInfo) (*OperationResult, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddRequest not implemented") +} +func (UnimplementedAutomatizatorServer) GetUserRequests(context.Context, *UserInfo) (*RequestLists, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetUserRequests not implemented") +} +func (UnimplementedAutomatizatorServer) mustEmbedUnimplementedAutomatizatorServer() {} + +// UnsafeAutomatizatorServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to AutomatizatorServer will +// result in compilation errors. +type UnsafeAutomatizatorServer interface { + mustEmbedUnimplementedAutomatizatorServer() +} + +func RegisterAutomatizatorServer(s grpc.ServiceRegistrar, srv AutomatizatorServer) { + s.RegisterService(&Automatizator_ServiceDesc, srv) +} + +func _Automatizator_AddRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RequestInfo) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AutomatizatorServer).AddRequest(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.Automatizator/AddRequest", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AutomatizatorServer).AddRequest(ctx, req.(*RequestInfo)) + } + return interceptor(ctx, in, info, handler) +} + +func _Automatizator_GetUserRequests_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UserInfo) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AutomatizatorServer).GetUserRequests(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.Automatizator/GetUserRequests", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AutomatizatorServer).GetUserRequests(ctx, req.(*UserInfo)) + } + return interceptor(ctx, in, info, handler) +} + +// Automatizator_ServiceDesc is the grpc.ServiceDesc for Automatizator service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Automatizator_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "grpc.Automatizator", + HandlerType: (*AutomatizatorServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "AddRequest", + Handler: _Automatizator_AddRequest_Handler, + }, + { + MethodName: "GetUserRequests", + Handler: _Automatizator_GetUserRequests_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "Automatization.proto", +} diff --git a/telegram-bot/telegram-bot.go b/telegram-bot/telegram-bot.go new file mode 100644 index 0000000..31805f0 --- /dev/null +++ b/telegram-bot/telegram-bot.go @@ -0,0 +1,126 @@ +package main + +import ( + "context" + "log" + "strings" + "time" + + plex "nikozavr.ru/plexautomatization/grpc" + + tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" + grpc "google.golang.org/grpc" +) + +const ( + address = "localhost:5000" + defaultName = "world" +) + +func main() { + conn, err := grpc.Dial(address, grpc.WithInsecure(), grpc.WithBlock()) + if err != nil { + log.Fatalf("did not connect: %v", err) + } + defer conn.Close() + c := plex.NewAutomatizatorClient(conn) + + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + + defer cancel() + + r, err := c.AddRequest(ctx, &plex.RequestInfo{UserId: 213}) + + if err != nil { + log.Fatalf("could not exec: %v", err) + } + + log.Printf("Result: %v", r.Message) + + bot, err := tgbotapi.NewBotAPI("1518526346:AAEA5BpB3iZRsiBSYJZBnWBiOqeWrFT59rg") + if err != nil { + log.Panic(err) + } + + bot.Debug = true + + log.Printf("Authorized on account %s", bot.Self.UserName) + + u := tgbotapi.NewUpdate(0) + u.Timeout = 60 + + userLists := make(map[int][]string) + processingList := make(map[int]bool) + + updates, err := bot.GetUpdatesChan(u) + + for update := range updates { + if update.Message == nil { // ignore any non-Message Updates + continue + } + + log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text) + log.Println(userLists) + + processing, ok := processingList[update.Message.From.ID] + + if !ok { + processingList[update.Message.From.ID] = false + processing = false + } + + if processing { + list, ok := userLists[update.Message.From.ID] + if !ok { + userLists[update.Message.From.ID] = []string{update.Message.Text} + } else { + userLists[update.Message.From.ID] = append(list, update.Message.Text) + } + + processingList[update.Message.From.ID] = false + msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Запрос добавлен") + bot.Send(msg) + continue + } + + if !update.Message.IsCommand() { + sticker := tgbotapi.NewStickerShare(update.Message.Chat.ID, "CAACAgIAAxkBAAEBzqVgDFwGwth9LYIyjZKcbPyYjec95gACAgEAAladvQpO4myBy0Dk_x4E") + bot.Send(sticker) + + msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Не понимаю Вас( Попробуйте использовать команды.") + bot.Send(msg) + continue + } + + answer := tgbotapi.NewMessage(update.Message.Chat.ID, "") + switch update.Message.Command() { + case "add": + trimmedCommandArguments := strings.TrimSpace(update.Message.CommandArguments()) + if trimmedCommandArguments == "" { + processingList[update.Message.From.ID] = true + answer.Text = "Введите название фильма или сериала, который вы хотели бы добавить в библиотеку Plex." + } else { + list, ok := userLists[update.Message.From.ID] + if !ok { + userLists[update.Message.From.ID] = []string{trimmedCommandArguments} + } else { + userLists[update.Message.From.ID] = append(list, trimmedCommandArguments) + } + answer.Text = "Запрос добавлен" + } + case "list": + list, ok := userLists[update.Message.From.ID] + if !ok || len(list) == 0 { + answer.Text = "Список пуст" + } else { + answer.Text = "Список запросов:\n" + strings.Join(list, "\n") + } + default: + answer.Text = "Команда не распознана. Попробуйте ещё раз." + } + + if _, err := bot.Send(answer); err != nil { + log.Panic(err) + } + } +}