예제 #1
0
 public Task AddAnimatedStickerToSetAsync(
     int userId,
     string name,
     InputFileStream tgsSticker,
     string emojis,
     MaskPosition maskPosition           = null,
     CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException();
예제 #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger <Startup> logger)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            InputFileStream sslCert = null;

            if (!string.IsNullOrEmpty(_appConfig.SSLCertPath))
            {
                sslCert = new InputFileStream(env.ContentRootFileProvider.GetFileInfo(_appConfig.SSLCertPath).CreateReadStream());
            }

            _botClient.DeleteWebhookAsync()
            .ContinueWith(async(t) => await _botClient.SetWebhookAsync(_appConfig.WebhookUrl, sslCert))
            .ContinueWith((t) => logger.LogInformation($"Set webhook to {_appConfig.WebhookUrl}, SSL cert is {sslCert?.ToString() ?? "null"}"));

            logger.LogInformation($"Configured HTTP pipeline. AppSettings is {_appConfig}");
        }
예제 #3
0
 /// <summary>
 /// Initializes a new request with userId, name tgsSticker and emojis
 /// </summary>
 /// <param name="userId">User identifier of sticker set owner</param>
 /// <param name="name">Sticker set name</param>
 /// <param name="tgsSticker">Tgs animation with the sticker</param>
 /// <param name="emojis">One or more emoji corresponding to the sticker</param>
 public AddAnimatedStickerToSetRequest(int userId, string name, InputFileStream tgsSticker, string emojis)
     : base("addStickerToSet")
 {
     UserId     = userId;
     Name       = name;
     TgsSticker = tgsSticker;
     Emojis     = emojis;
 }
예제 #4
0
 public Task CreateNewAnimatedStickerSetAsync(
     int userId,
     string name,
     string title,
     InputFileStream tgsSticker,
     string emojis,
     bool isMasks = false,
     MaskPosition maskPosition           = null,
     CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException();
예제 #5
0
        public void Should_Serialize_Input_File_Stream()
        {
            InputFileStream inputFile = new MemoryStream();

            string          json = JsonConvert.SerializeObject(inputFile);
            InputFileStream obj  = JsonConvert.DeserializeObject <InputFileStream>(json);

            Assert.Equal("null", json);
            Assert.Equal(Stream.Null, obj.Content);
            Assert.Equal(FileType.Stream, obj.FileType);
            Assert.Null(obj.FileName);
        }
예제 #6
0
        public void Should_Serialize_Input_File_Stream()
        {
            InputFileStream inputFile = new MemoryStream();

            string          json = JsonSerializer.Serialize(inputFile, new JsonSerializerOptions(JsonSerializerDefaults.Web));
            InputFileStream obj  = JsonSerializer.Deserialize <InputFileStream>(json, new JsonSerializerOptions(JsonSerializerDefaults.Web));

            Assert.Equal("null", json);
            Assert.Equal(Stream.Null, obj.Content);
            Assert.Equal(FileType.Stream, obj.FileType);
            Assert.Null(obj.FileName);
        }
 /// <summary>
 /// Initializes a new request with userId, name, tgsSticker and emojis
 /// </summary>
 /// <param name="userId">User identifier of sticker set owner</param>
 /// <param name="name">Sticker set name</param>
 /// <param name="title">Sticker set title, 1-64 characters</param>
 /// <param name="tgsSticker">Tgs animation with the sticker</param>
 /// <param name="emojis">One or more emoji corresponding to the sticker</param>
 public CreateNewAnimatedStickerSetRequest(
     long userId,
     string name,
     string title,
     InputFileStream tgsSticker,
     string emojis)
     : base("createNewStickerSet")
 {
     UserId     = userId;
     Name       = name;
     Title      = title;
     TgsSticker = tgsSticker;
     Emojis     = emojis;
 }
예제 #8
0
        private Stream GetInput()
        {
            FileStream input = null;

            try {
                MD5 md5 = MD5.Create();
                input = new InputFileStream(this, md5);
                if (!input.CanRead)
                {
                    return(null);
                }

                return(input);
            } catch (Exception) {
                if (input != null)
                {
                    input.Close();
                }

                return(null);
            }
        }
예제 #9
0
 /// <summary>
 /// Initializes a new request with chatId and photo
 /// </summary>
 /// <param name="chatId">Unique identifier for the target chat or username of the target channel</param>
 /// <param name="photo">New chat photo</param>
 public SetChatPhotoRequest(ChatId chatId, InputFileStream photo)
     : base("setChatPhoto")
 {
     ChatId = chatId;
     Photo  = photo;
 }
예제 #10
0
        public MultipartFormDataContent ToMultipartFormDataContent(string fileParameterName, InputFileStream inputFile)
        {
            string boundary         = Guid.NewGuid().ToString();
            var    multipartContent = new MultipartFormDataContent(boundary);

            //https://stackoverflow.com/questions/30926645/httpcontent-boundary-double-quotes
            //https://blog.codetitans.pl/post/quoted-boundary-is-sometimes-not-acceptable/
            multipartContent.Headers.Remove("Content-Type");
            multipartContent.Headers.TryAddWithoutValidation("Content-Type", "multipart/form-data; boundary=" + boundary);

            multipartContent.AddStreamContent(inputFile.Content, fileParameterName, inputFile.FileName);
            return(multipartContent);
        }
예제 #11
0
 /// <summary>
 /// Initializes a new request with uri
 /// </summary>
 /// <param name="url">HTTPS url to send updates to</param>
 /// <param name="certificate">ToDo</param>
 public SetWebhookRequest(string url, InputFileStream certificate)
     : base("setWebhook")
 {
     Url         = url;
     Certificate = certificate;
 }
예제 #12
0
 public Task SetWebhookAsync(
     string url,
     InputFileStream certificate             = null,
     int maxConnections                      = 0,
     IEnumerable <UpdateType> allowedUpdates = null,
     CancellationToken cancellationToken     = new CancellationToken()) => throw new NotImplementedException();
예제 #13
0
 public Task SetChatPhotoAsync(
     ChatId chatId,
     InputFileStream photo,
     CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException();
예제 #14
0
 public Task <File> UploadStickerFileAsync(
     int userId,
     InputFileStream pngSticker,
     CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException();
예제 #15
0
        /// <summary>
        /// ToDo
        /// </summary>
        /// <param name="fileParameterName"></param>
        /// <param name="inputFile"></param>
        /// <returns></returns>
        protected MultipartFormDataContent ToMultipartFormDataContent(string fileParameterName, InputFileStream inputFile)
        {
            var multipartContent = GenerateMultipartFormDataContent(fileParameterName);

            multipartContent.AddStreamContent(inputFile.Content, fileParameterName, inputFile.FileName);

            return(multipartContent);
        }
예제 #16
0
        private Stream GetInput()
        {
            FileStream input = null;

            try {
                MD5 md5 = MD5.Create();
                input = new InputFileStream(this, md5);
                if (!input.CanRead)
                    return null;

                return input;
            } catch (Exception) {
                if (input != null)
                    input.Close();

                return null;
            }
        }
 /// <summary>
 /// Initializes a new request with userId and pngSticker
 /// </summary>
 public UploadStickerFileRequest(long userId, InputFileStream pngSticker)
     : base("uploadStickerFile")
 {
     UserId     = userId;
     PngSticker = pngSticker;
 }