Integrating Images Project
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -422,44 +420,6 @@ namespace TelegramBotBase.Sessions
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an image
|
||||
/// </summary>
|
||||
/// <param name="image"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="buttons"></param>
|
||||
/// <param name="replyTo"></param>
|
||||
/// <param name="disableNotification"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Message> SendPhoto(Image image, String name, String caption, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false)
|
||||
{
|
||||
using (var fileStream = Tools.Images.ToStream(image, ImageFormat.Png))
|
||||
{
|
||||
InputOnlineFile fts = new InputOnlineFile(fileStream, name);
|
||||
|
||||
return await SendPhoto(fts, caption: caption, buttons, replyTo, disableNotification);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an image
|
||||
/// </summary>
|
||||
/// <param name="image"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="buttons"></param>
|
||||
/// <param name="replyTo"></param>
|
||||
/// <param name="disableNotification"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Message> SendPhoto(Bitmap image, String name, String caption, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false)
|
||||
{
|
||||
using (var fileStream = Tools.Images.ToStream(image, ImageFormat.Png))
|
||||
{
|
||||
InputOnlineFile fts = new InputOnlineFile(fileStream, name);
|
||||
|
||||
return await SendPhoto(fts, caption: caption, buttons, replyTo, disableNotification);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an video
|
||||
/// </summary>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.1;net472;net5;netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.1;net472;net5;netcoreapp3.1;net6</TargetFrameworks>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<PackageProjectUrl>https://github.com/MajMcCloud/TelegramBotFramework</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/MajMcCloud/TelegramBotFramework</RepositoryUrl>
|
||||
@@ -16,6 +16,9 @@
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<Version>$(VersionPrefix)</Version>
|
||||
<AssemblyVersion></AssemblyVersion>
|
||||
<FileVersion></FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -28,7 +31,7 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
@@ -64,10 +67,8 @@
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="System.ComponentModel" Version="4.3.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||
<PackageReference Include="Telegram.Bot" Version="17.0.0" />
|
||||
<PackageReference Include="Telegram.Bot.Extensions.Polling" Version="1.0.0" />
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Tools
|
||||
{
|
||||
public static class Images
|
||||
{
|
||||
public static Stream ToStream(this Image image, ImageFormat format)
|
||||
{
|
||||
var stream = new System.IO.MemoryStream();
|
||||
image.Save(stream, format);
|
||||
stream.Position = 0;
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user