mirror of
https://github.com/opengram-server/opengram.git
synced 2026-09-15 06:54:15 +03:00
Initial commit
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<ConfigureAwait ContinueOnCapturedContext="false" />
|
||||
</Weavers>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
|
||||
<xs:element name="Weavers">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
<xs:attribute name="VerifyAssembly" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="GenerateXsd" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -0,0 +1,58 @@
|
||||
using Grpc.Net.Client;
|
||||
|
||||
namespace MyTelegram.GrpcService;
|
||||
|
||||
public static class GrpcClientFactory
|
||||
{
|
||||
private static IdGeneratorService.IdGeneratorServiceClient? _idGeneratorServiceClient;
|
||||
private static MediaService.MediaServiceClient? _mediaServiceClient;
|
||||
|
||||
public static IdGeneratorService.IdGeneratorServiceClient CreateIdGeneratorServiceClient(string address,
|
||||
bool forceRecreate = false)
|
||||
{
|
||||
if (_idGeneratorServiceClient == null || forceRecreate)
|
||||
{
|
||||
var handler = new SocketsHttpHandler
|
||||
{
|
||||
PooledConnectionIdleTimeout = Timeout.InfiniteTimeSpan,
|
||||
KeepAlivePingDelay = TimeSpan.FromSeconds(60),
|
||||
KeepAlivePingTimeout = TimeSpan.FromSeconds(30),
|
||||
EnableMultipleHttp2Connections = true
|
||||
};
|
||||
|
||||
var channel = GrpcChannel.ForAddress(address, new GrpcChannelOptions
|
||||
{
|
||||
HttpHandler = handler
|
||||
});
|
||||
_idGeneratorServiceClient = new IdGeneratorService.IdGeneratorServiceClient(channel);
|
||||
}
|
||||
|
||||
return _idGeneratorServiceClient;
|
||||
}
|
||||
|
||||
public static MediaService.MediaServiceClient CreateMediaServiceClient(string address)
|
||||
{
|
||||
if (_mediaServiceClient == null)
|
||||
{
|
||||
var channel = GrpcChannel.ForAddress(address,
|
||||
new GrpcChannelOptions
|
||||
{
|
||||
HttpHandler = CreateHttpHandler()
|
||||
});
|
||||
_mediaServiceClient = new MediaService.MediaServiceClient(channel);
|
||||
}
|
||||
|
||||
return _mediaServiceClient;
|
||||
}
|
||||
|
||||
private static HttpMessageHandler CreateHttpHandler()
|
||||
{
|
||||
return new SocketsHttpHandler
|
||||
{
|
||||
PooledConnectionIdleTimeout = Timeout.InfiniteTimeSpan,
|
||||
KeepAlivePingDelay = TimeSpan.FromSeconds(60),
|
||||
KeepAlivePingTimeout = TimeSpan.FromSeconds(30),
|
||||
EnableMultipleHttp2Connections = true
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Protos\botservice.proto" />
|
||||
<None Remove="Protos\chatmemberloaderservice.proto" />
|
||||
<None Remove="Protos\chatservice.proto" />
|
||||
<None Remove="Protos\idgeneratorservice.proto" />
|
||||
<None Remove="Protos\mediaservice.proto" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" />
|
||||
<!--<PackageReference Include="Grpc" Version="2.46.3" />-->
|
||||
<PackageReference Include="Grpc.Net.Client" />
|
||||
<PackageReference Include="Grpc.Tools">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!--<Protobuf Include="Protos\chatservice.proto" />-->
|
||||
<Protobuf Include="Protos\chatmemberloaderservice.proto" GrpcServices="Server" />
|
||||
<Protobuf Include="Protos\idgeneratorservice.proto" GrpcServices="Client" />
|
||||
<Protobuf Include="Protos\mediaservice.proto" GrpcServices="Client" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Fody">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,30 @@
|
||||
syntax = "proto3";
|
||||
|
||||
//import "google/protobuf/empty.proto";
|
||||
|
||||
option csharp_namespace = "MyTelegram.GrpcService";
|
||||
|
||||
package MyTelegram.GrpcService;
|
||||
|
||||
service BotService {
|
||||
rpc GetBotInfo(.MyTelegram.GrpcService.GetBotInfoRequest) returns (.MyTelegram.GrpcService.GetBotInfoResponse);
|
||||
}
|
||||
|
||||
message GetBotInfoRequest{
|
||||
int64 BotUserId=1;
|
||||
}
|
||||
|
||||
message GetBotInfoResponse{
|
||||
int64 BotUserId=1;
|
||||
bool AllJoinToGroups=2;
|
||||
bool AllowAccessGroupMessages=3;
|
||||
string UserName=4;
|
||||
string Description=5;
|
||||
string About=6;
|
||||
repeated BotCommand Commands=7;
|
||||
}
|
||||
|
||||
message BotCommand{
|
||||
string Command=1;
|
||||
string Description=2;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option csharp_namespace="MyTelegram.GrpcService";
|
||||
|
||||
package MyTelegram.GrpcService;
|
||||
|
||||
service ChatMemberLoaderService{
|
||||
rpc GetChatMembers (.MyTelegram.GrpcService.GetChatMemberRequest) returns(.MyTelegram.GrpcService.GetChatMemberResponse);
|
||||
rpc GetChannelMembers(.MyTelegram.GrpcService.GetChannelMemberRequest) returns(.MyTelegram.GrpcService.GetChannelMemberResponse);
|
||||
}
|
||||
|
||||
message GetChatMemberRequest{
|
||||
int64 ChatId=1;
|
||||
}
|
||||
|
||||
message GetChatMemberResponse{
|
||||
repeated int64 ChatMemberUidList=1;
|
||||
}
|
||||
|
||||
message GetChannelMemberRequest{
|
||||
int64 ChannelId=1;
|
||||
}
|
||||
|
||||
message GetChannelMemberResponse{
|
||||
repeated int64 ChannelMemberUidList=1;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option csharp_namespace="MyTelegram.GrpcService";
|
||||
|
||||
package MyTelegram.GrpcService;
|
||||
|
||||
service ChatService{
|
||||
rpc GetChannel(.MyTelegram.GrpcService.GetChannelRequest) returns(.MyTelegram.GrpcService.GetChannelResponse);
|
||||
}
|
||||
|
||||
message GetChannelRequest{
|
||||
int64 ChannelId=1;
|
||||
int64 SelfUserId=2;
|
||||
}
|
||||
|
||||
message GetChannelResponse{
|
||||
bytes ChannelData=1;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
syntax = "proto3";
|
||||
|
||||
//import "google/protobuf/empty.proto";
|
||||
|
||||
option csharp_namespace = "MyTelegram.GrpcService";
|
||||
|
||||
package MyTelegram.GrpcService;
|
||||
|
||||
service IdGeneratorService {
|
||||
rpc GetNextSeqId(.MyTelegram.GrpcService.GetNextSeqIdRequest) returns (.MyTelegram.GrpcService.GetNextSeqIdResponse);
|
||||
rpc GenerateServerMessageId (.MyTelegram.GrpcService.GenerateServerMessageIdRequest) returns (.MyTelegram.GrpcService.GenerateServerMessageIdResponse);
|
||||
rpc GenerateNextHighValue(.MyTelegram.GrpcService.GenerateNextHighValueRequest) returns(.MyTelegram.GrpcService.GenerateNextHighValueResponse);
|
||||
}
|
||||
|
||||
message GetNextSeqIdRequest{
|
||||
int32 IdType=1;
|
||||
int64 IdKey=2;
|
||||
int32 Step=3;
|
||||
}
|
||||
|
||||
message GetNextSeqIdResponse{
|
||||
int64 SeqId=1;
|
||||
}
|
||||
|
||||
message GenerateServerMessageIdRequest{
|
||||
}
|
||||
|
||||
message GenerateServerMessageIdResponse{
|
||||
int64 MessageId=1;
|
||||
}
|
||||
|
||||
message GenerateNextHighValueRequest{
|
||||
int32 IdType=1;
|
||||
int64 IdKey=2;
|
||||
}
|
||||
|
||||
message GenerateNextHighValueResponse{
|
||||
int64 HighValue=1;
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option csharp_namespace = "MyTelegram.GrpcService";
|
||||
|
||||
package MyTelegram.GrpcService;
|
||||
|
||||
service MediaService {
|
||||
//rpc GetFileMetadata(.MyTelegram.GrpcService.GetFileMetadataRequest) returns(.MyTelegram.GrpcService.GetFileMetadataResponse);
|
||||
rpc SaveEncryptedFile(.MyTelegram.GrpcService.SaveEncryptedFileRequest) returns(.MyTelegram.GrpcService.SaveEncryptedFileResponse);
|
||||
rpc SavePhoto(.MyTelegram.GrpcService.SavePhotoRequest)returns(.MyTelegram.GrpcService.SavePhotoResponse);
|
||||
rpc SaveMedia(.MyTelegram.GrpcService.SaveMediaRequest)returns (.MyTelegram.GrpcService.SaveMediaResponse);
|
||||
rpc SaveStickerFile(.MyTelegram.GrpcService.SaveStickerFileRequest) returns(.MyTelegram.GrpcService.SaveStickerFileResponse);
|
||||
rpc CreateDocument(.MyTelegram.GrpcService.CreateDocumentRequest) returns(.MyTelegram.GrpcService.CreateDocumentResponse);
|
||||
rpc SaveFile(.MyTelegram.GrpcService.SaveFileDataRequest) returns (.MyTelegram.GrpcService.SaveFileDataResponse);
|
||||
rpc Exists(.MyTelegram.GrpcService.CheckFileExistsRequest) returns (.MyTelegram.GrpcService.CheckFileExistsResponse);
|
||||
}
|
||||
|
||||
message GetFileMetadataRequest{
|
||||
int64 fileId=1;
|
||||
}
|
||||
|
||||
message GetFileMetadataResponse{
|
||||
//int64 fileId=1;
|
||||
int64 volumeId=2;
|
||||
int64 serverFileId=3;
|
||||
int64 accessHash=4;
|
||||
int32 size=5;
|
||||
int32 localId=6;
|
||||
int32 date=7;
|
||||
string mimeType=8;
|
||||
int64 thumbFileId=9;
|
||||
bytes attributes=10;
|
||||
bytes thumbs=11;
|
||||
}
|
||||
|
||||
message SavePhotoRequest{
|
||||
int64 reqMsgId=1;
|
||||
int64 fileId=2;
|
||||
bool hasVideo=3;
|
||||
double videoStartTs=4;
|
||||
int32 parts=5;
|
||||
string name=6;
|
||||
string md5=7;
|
||||
optional bytes videoEmojiMarkup=8;
|
||||
int64 userId=9;
|
||||
bool isProfilePhoto=10;
|
||||
}
|
||||
|
||||
message SavePhotoResponse{
|
||||
//int64 serverFileId=1;
|
||||
//int64 accessHash=2;
|
||||
//int32 date=3;
|
||||
//int32 size=4;
|
||||
//int32 height=5;
|
||||
//int32 width=6;
|
||||
bytes photo=1;
|
||||
int64 photoId=2;
|
||||
int64 size=3;
|
||||
}
|
||||
|
||||
message SaveMediaRequest{
|
||||
bytes media=1;
|
||||
int64 userId=2;
|
||||
}
|
||||
|
||||
message SaveMediaResponse{
|
||||
bytes media=1;
|
||||
}
|
||||
|
||||
message SaveEncryptedFileRequest{
|
||||
bytes encryptedFile=1;
|
||||
int64 reqMsgId=2;
|
||||
}
|
||||
|
||||
message SaveEncryptedFileResponse{
|
||||
//bytes encryptedFile=1;
|
||||
int64 accessHash=1;
|
||||
int32 dcId=2;
|
||||
int64 id=3;
|
||||
int32 keyFingerprint=4;
|
||||
int64 size=5;
|
||||
}
|
||||
|
||||
message SaveStickerFileRequest{
|
||||
int64 stickerSetId=1;
|
||||
int64 stickerSetAccessHash=2;
|
||||
int64 stickerId=3;
|
||||
string mimeType=4;
|
||||
int32 size=5;
|
||||
bytes data=6;
|
||||
string thumbSize=7;
|
||||
string emoji=8;
|
||||
bool isAnimated=9;
|
||||
int64 accessHash=10;
|
||||
bytes fileReference=11;
|
||||
string thumb=12;
|
||||
string videoThumb=13;
|
||||
//int32 StickerFileType=13;//1.sticker thumb 2.sticker 3.sticker thumb 4.sticker video thumb
|
||||
bool createMetadata=14;
|
||||
}
|
||||
|
||||
message SaveStickerFileResponse{
|
||||
bool success=1;
|
||||
}
|
||||
|
||||
message CreateDocumentRequest{
|
||||
int64 stickerSetId=1;
|
||||
int64 stickerSetAccessHash=2;
|
||||
int64 stickerId=3;
|
||||
int64 accessHash=4;
|
||||
string mimeType=5;
|
||||
int32 size=6;
|
||||
string thumbSize=7;
|
||||
string emoji=8;
|
||||
bool isAnimated=9;
|
||||
string thumb=10;
|
||||
string videoThumb=11;
|
||||
bytes fileReference=12;
|
||||
string attributeFileName=13;
|
||||
int32 stickerType=14;
|
||||
}
|
||||
|
||||
message CreateDocumentResponse{
|
||||
bool success=1;
|
||||
}
|
||||
|
||||
message SaveFileDataRequest{
|
||||
int64 id=1;
|
||||
int64 accessHash=2;
|
||||
bytes data=3;
|
||||
string thumbSize=4;
|
||||
}
|
||||
|
||||
message SaveFileDataResponse{
|
||||
bool success=1;
|
||||
}
|
||||
|
||||
message CheckFileExistsRequest{
|
||||
string fileName=1;
|
||||
}
|
||||
|
||||
message CheckFileExistsResponse{
|
||||
bool exists=1;
|
||||
}
|
||||
Reference in New Issue
Block a user