Compare commits

...
2 Commits
Author SHA1 Message Date
BlubbFish 75f53ca419 rewrite for .netcore and .netframework 2026-08-04 12:13:36 +02:00
BlubbFish b498114f48 add dependencys
fixing tiny stuff so its up to date
add .gitignore
2019-02-14 21:49:23 +01:00
7 changed files with 307 additions and 221 deletions
+4
View File
@@ -0,0 +1,4 @@
/packages
/.vs
/ConnectorUserTelegram/obj
/ConnectorUserTelegram/bin
+37
View File
@@ -0,0 +1,37 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorUserTelegram-4.7.1", "ConnectorUserTelegram\ConnectorUserTelegram-4.7.1.csproj", "{E66A57DD-858A-40E4-8A2F-BEA5129C31F7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils-IoT-4.7.1", "..\Utils-IoT\Utils-IoT\Utils-IoT-4.7.1.csproj", "{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "litjson_4.7.1", "..\..\Librarys\litjson\litjson\litjson_4.7.1.csproj", "{91A14CD2-2940-4500-8193-56D37EDDDBAA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E66A57DD-858A-40E4-8A2F-BEA5129C31F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E66A57DD-858A-40E4-8A2F-BEA5129C31F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E66A57DD-858A-40E4-8A2F-BEA5129C31F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E66A57DD-858A-40E4-8A2F-BEA5129C31F7}.Release|Any CPU.Build.0 = Release|Any CPU
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.Build.0 = Release|Any CPU
{91A14CD2-2940-4500-8193-56D37EDDDBAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91A14CD2-2940-4500-8193-56D37EDDDBAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91A14CD2-2940-4500-8193-56D37EDDDBAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91A14CD2-2940-4500-8193-56D37EDDDBAA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7C826771-09A9-44C6-BC5F-E7E8BABFD2A3}
EndGlobalSection
EndGlobal
+43 -31
View File
@@ -1,31 +1,43 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio Version 16
VisualStudioVersion = 15.0.28307.136 VisualStudioVersion = 16.0.31112.23
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorUserTelegram", "ConnectorUserTelegram\ConnectorUserTelegram.csproj", "{E66A57DD-858A-40E4-8A2F-BEA5129C31F7}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorUserTelegram", "ConnectorUserTelegram\ConnectorUserTelegram.csproj", "{47608208-8DFE-4E9D-8F9B-FFD1A82298F2}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils-IoT", "..\Utils-IoT\Utils-IoT\Utils-IoT.csproj", "{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utils-IoT", "..\Utils-IoT\Utils-IoT\Utils-IoT.csproj", "{E0265DBD-6DA0-4E40-837A-8CB11F374562}"
EndProject EndProject
Global Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utils", "..\Utils\Utils\Utils.csproj", "{E8263A61-A7C8-4DDF-9E29-873B80C63C76}"
GlobalSection(SolutionConfigurationPlatforms) = preSolution EndProject
Debug|Any CPU = Debug|Any CPU Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "litjson", "..\..\Librarys\litjson\litjson\litjson.csproj", "{8152C622-E81D-4E52-AB55-686B7AD5B89A}"
Release|Any CPU = Release|Any CPU EndProject
EndGlobalSection Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
{E66A57DD-858A-40E4-8A2F-BEA5129C31F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
{E66A57DD-858A-40E4-8A2F-BEA5129C31F7}.Debug|Any CPU.Build.0 = Debug|Any CPU Release|Any CPU = Release|Any CPU
{E66A57DD-858A-40E4-8A2F-BEA5129C31F7}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection
{E66A57DD-858A-40E4-8A2F-BEA5129C31F7}.Release|Any CPU.Build.0 = Release|Any CPU GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {47608208-8DFE-4E9D-8F9B-FFD1A82298F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.Build.0 = Debug|Any CPU {47608208-8DFE-4E9D-8F9B-FFD1A82298F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.ActiveCfg = Release|Any CPU {47608208-8DFE-4E9D-8F9B-FFD1A82298F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.Build.0 = Release|Any CPU {47608208-8DFE-4E9D-8F9B-FFD1A82298F2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection {E0265DBD-6DA0-4E40-837A-8CB11F374562}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
GlobalSection(SolutionProperties) = preSolution {E0265DBD-6DA0-4E40-837A-8CB11F374562}.Debug|Any CPU.Build.0 = Debug|Any CPU
HideSolutionNode = FALSE {E0265DBD-6DA0-4E40-837A-8CB11F374562}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection {E0265DBD-6DA0-4E40-837A-8CB11F374562}.Release|Any CPU.Build.0 = Release|Any CPU
GlobalSection(ExtensibilityGlobals) = postSolution {E8263A61-A7C8-4DDF-9E29-873B80C63C76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
SolutionGuid = {7C826771-09A9-44C6-BC5F-E7E8BABFD2A3} {E8263A61-A7C8-4DDF-9E29-873B80C63C76}.Debug|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection {E8263A61-A7C8-4DDF-9E29-873B80C63C76}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobal {E8263A61-A7C8-4DDF-9E29-873B80C63C76}.Release|Any CPU.Build.0 = Release|Any CPU
{8152C622-E81D-4E52-AB55-686B7AD5B89A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8152C622-E81D-4E52-AB55-686B7AD5B89A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8152C622-E81D-4E52-AB55-686B7AD5B89A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8152C622-E81D-4E52-AB55-686B7AD5B89A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {079546FF-493E-49AC-8637-06AAB35FE782}
EndGlobalSection
EndGlobal
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E66A57DD-858A-40E4-8A2F-BEA5129C31F7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BlubbFish.Utils.IoT.Connector.User</RootNamespace>
<AssemblyName>ConnectorUserTelegram</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.AppContext, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Telegram.Bot, Version=13.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Telegram.Bot.13.2.1\lib\netstandard1.1\Telegram.Bot.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Telegram.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Utils-IoT\Utils-IoT\Utils-IoT-4.7.1.csproj">
<Project>{b870e4d5-6806-4a0b-b233-8907eedc5afc}</Project>
<Name>Utils-IoT</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -1,120 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk">
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup>
<PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> </PropertyGroup>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E66A57DD-858A-40E4-8A2F-BEA5129C31F7}</ProjectGuid> <ItemGroup>
<OutputType>Library</OutputType> <PackageReference Include="Telegram.Bot" Version="18.0.0" />
<AppDesignerFolder>Properties</AppDesignerFolder> </ItemGroup>
<RootNamespace>BlubbFish.Utils.IoT.Connector.User</RootNamespace>
<AssemblyName>ConnectorUserTelegram</AssemblyName> <ItemGroup>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion> <ProjectReference Include="..\..\Utils-IoT\Utils-IoT\Utils-IoT.csproj" />
<FileAlignment>512</FileAlignment> </ItemGroup>
<TargetFrameworkProfile />
</PropertyGroup> </Project>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Win32.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.AppContext, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Console, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.Console.4.3.0\lib\net46\System.Console.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.Globalization.Calendars, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll</HintPath>
</Reference>
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.IO.Compression.ZipFile, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll</HintPath>
</Reference>
<Reference Include="System.IO.FileSystem, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll</HintPath>
</Reference>
<Reference Include="System.IO.FileSystem.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.Net.Http.4.3.0\lib\net46\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Net.Sockets, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.ReaderWriter, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll</HintPath>
</Reference>
<Reference Include="Telegram.Bot, Version=13.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Telegram.Bot.13.2.1\lib\netstandard1.1\Telegram.Bot.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Telegram.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Utils-IoT.csproj">
<Project>{b870e4d5-6806-4a0b-b233-8907eedc5afc}</Project>
<Name>Utils-IoT</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -1,4 +1,5 @@
using System.Reflection; #if !NETCOREAPP
using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@@ -34,3 +35,7 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
#endif
/*
* 1.0.0.0 Init
*/
+126 -69
View File
@@ -1,69 +1,126 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Telegram.Bot; using System.Threading;
using Telegram.Bot.Args; using System.Threading.Tasks;
using Telegram.Bot.Exceptions;
using Telegram.Bot.Types; using BlubbFish.Utils.IoT.Events;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups; using Telegram.Bot;
using Telegram.Bot.Exceptions;
namespace BlubbFish.Utils.IoT.Connector.User { using Telegram.Bot.Polling;
public class Telegram : AUserBackend { using Telegram.Bot.Types;
private TelegramBotClient bot; using Telegram.Bot.Types.Enums;
private ChatId chat; using Telegram.Bot.Types.ReplyMarkups;
public override event TelegramMessage MessageIncomming; namespace BlubbFish.Utils.IoT.Connector.User {
public override event TelegramMessage MessageSending; public class Telegram : AUserBackend {
private readonly TelegramBotClient bot;
public Telegram(Dictionary<String, String> settings) : base(settings) { private readonly CancellationTokenSource cts;
this.bot = new TelegramBotClient(settings["telegram-key"]); private readonly Dictionary<String, ChatId> chat = new Dictionary<String, ChatId>();
this.bot.OnMessage += this.Bot_OnMessage;
this.Connect(); public override Boolean IsConnected => true;
}
public Telegram(Dictionary<String, String> settings) : base(settings) {
private void Bot_OnMessage(Object sender, MessageEventArgs e) { this.cts = new CancellationTokenSource();
this.MessageIncomming?.Invoke(this, new UserMessageEventArgs(e.Message.Text, e.Message.Chat.Id, e.Message.Date)); this.bot = new TelegramBotClient(settings["telegram-key"]);
} this.Connect();
}
private void Connect() {
this.bot.StartReceiving(); private void Connect() {
this.chat = new ChatId(this.settings["chatid"]); this.bot.StartReceiving(
} updateHandler: this.HandleUpdateAsync,
pollingErrorHandler: this.HandlePollingErrorAsync,
public async override void Send(String message) { receiverOptions: new ReceiverOptions { AllowedUpdates = Array.Empty<UpdateType>() },
try { cancellationToken: this.cts.Token
Message x = await this.bot.SendTextMessageAsync(this.chat, message, ParseMode.Default, false, false, 0, new ReplyKeyboardRemove()); );
this.MessageSending?.Invoke(this, new UserMessageEventArgs(x.Text, x.Chat.Id, x.Date)); _ = this.bot.GetMeAsync();
} catch(ApiRequestException e) { Console.WriteLine("BlubbFish.Utils.IoT.Connector.User.Telegram.Connect(): Connected to Telegram");
Console.ForegroundColor = ConsoleColor.Red; }
Console.WriteLine(e.Message+" "+e.ErrorCode+" "+e.Parameters);
Console.ForegroundColor = ConsoleColor.White; private ChatId GetChatId(String chatid) {
} if(!this.chat.ContainsKey(chatid)) {
this.chat.Add(chatid, new ChatId(chatid));
} }
return this.chat[chatid];
public override void Dispose() { }
this.bot.StopReceiving();
this.bot = null; private async Task HandleUpdateAsync(ITelegramBotClient botClient, Update update, CancellationToken cancellationToken) {
} if(!(update.Message is { } message)) {
return;
public async override void Send(String message, String[] buttons) { }
try { if(!(message.Text is { } messageText)) {
KeyboardButton[][] button = new KeyboardButton[(Int32)Math.Ceiling(((Double)buttons.Length)/2)][]; return;
for(Int32 i = 0; i < buttons.Length; i++) { }
Int32 j = (Int32)Math.Floor(((Double)i) / 2); await Task.Run(() => this.NotifyClientIncomming(new UserEvent(messageText, new Tuple<Int64, String, Int64, String>(message.From.Id, message.From.Username, message.Chat.Id, message.ReplyToMessage?.Text), message.Date)));
if (i % 2 == 0) { }
button[j] = new KeyboardButton[(j == button.Length - 1) ? ((buttons.Length % 2 == 0) ? 2 : buttons.Length % 2) : 2];
} private Task HandlePollingErrorAsync(ITelegramBotClient botClient, Exception exception, CancellationToken cancellationToken) {
button[j][i % 2] = new KeyboardButton(buttons[i]); String ErrorMessage = exception switch {
} ApiRequestException apiRequestException => $"Telegram API Error:\n[{apiRequestException.ErrorCode}]\n{apiRequestException.Message}",
Message x = await this.bot.SendTextMessageAsync(this.chat, message, ParseMode.Default, false, false, 0, new ReplyKeyboardMarkup(button,true,true)); _ => exception.ToString()
this.MessageSending?.Invoke(this, new UserMessageEventArgs(x.Text, x.Chat.Id, x.Date)); };
} catch (ApiRequestException e) {
Console.ForegroundColor = ConsoleColor.Red; Helper.WriteError(ErrorMessage);
Console.WriteLine(e.Message + " " + e.ErrorCode + " " + e.Parameters); return Task.CompletedTask;
Console.ForegroundColor = ConsoleColor.White; }
}
} public async override void Send(String message) => await Task.Run(() => this.Send(message, this.settings["default-chat"]));
}
} public async void Send(String message, String chatid) {
try {
Message sentMessage = await this.bot.SendTextMessageAsync(
chatId: this.GetChatId(chatid),
text: message,
cancellationToken: this.cts.Token,
replyMarkup: new ReplyKeyboardRemove()
);
this.NotifyClientSending(new UserEvent(sentMessage.Text, new Tuple<Int64, String, Int64, String>(sentMessage.Chat.Id, "", 0, ""), sentMessage.Date));
} catch(ApiRequestException apiRequestException) {
Helper.WriteError($"Telegram API Error:\n[{apiRequestException.ErrorCode}]\n{apiRequestException.Message}");
}
}
public async void SendWithButtons(String message, String[] buttons, String chatid) {
try {
KeyboardButton[][] button = new KeyboardButton[(Int32)Math.Ceiling((Double)buttons.Length/2)][];
for(Int32 i = 0; i < buttons.Length; i++) {
Int32 j = (Int32)Math.Floor((Double)i / 2);
if (i % 2 == 0) {
button[j] = new KeyboardButton[(j == button.Length - 1) ? ((buttons.Length % 2 == 0) ? 2 : buttons.Length % 2) : 2];
}
button[j][i % 2] = new KeyboardButton(buttons[i]);
}
Message sentMessage = await this.bot.SendTextMessageAsync(
chatId: this.GetChatId(chatid),
text: message,
cancellationToken: this.cts.Token,
replyMarkup: new ReplyKeyboardMarkup(button)
);
this.NotifyClientSending(new UserEvent(sentMessage.Text, new Tuple<Int64, String, Int64, String>(sentMessage.Chat.Id, "", 0, ""), sentMessage.Date));
} catch (ApiRequestException apiRequestException) {
Helper.WriteError($"Telegram API Error:\n[{apiRequestException.ErrorCode}]\n{apiRequestException.Message}");
}
}
public async void SendLocationWithText(String title, String text, Double lat, Double lon, String chatid) {
try {
Message sentMessage = await this.bot.SendVenueAsync(
chatId: this.GetChatId(chatid),
title: title,
address: text,
cancellationToken: this.cts.Token,
latitude: lat,
longitude: lon
);
this.NotifyClientSending(new UserEvent("{" + lat + ", " + lon + "}" + title + ": " + text, new Tuple<Int64, String, Int64, String>(sentMessage.Chat.Id, "", 0, ""), sentMessage.Date));
} catch(ApiRequestException apiRequestException) {
Helper.WriteError($"Telegram API Error:\n[{apiRequestException.ErrorCode}]\n{apiRequestException.Message}");
}
}
public override void Dispose() {
this.cts.Cancel();
Console.WriteLine("BlubbFish.Utils.IoT.Connector.User.Telegram.Dispose(): Disconnected from Telegram");
}
}
}