Skip to content
This repository has been archived by the owner on Jan 10, 2022. It is now read-only.

Commit

Permalink
NoobDevBot: Initialize Git Repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Gallimathias committed Jul 10, 2016
1 parent bb619a5 commit 62a12c6
Show file tree
Hide file tree
Showing 10 changed files with 304 additions and 4 deletions.
14 changes: 14 additions & 0 deletions NoobDevBot(Stream)/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
91 changes: 91 additions & 0 deletions NoobDevBot(Stream)/NoobDevBot(Stream).csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" 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>{27A6E8B1-F7C7-4CB7-AE69-E240ED7D9971}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NoobDevBot</RootNamespace>
<AssemblyName>NoobDevBot</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="NAudio, Version=1.7.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NAudio.1.7.3\lib\net35\NAudio.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NAudio.Lame, Version=1.0.3.3048, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NAudio.Lame.1.0.4\lib\net20\NAudio.Lame.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Speech" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Telegram.Bot, Version=10.3.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Telegram.Bot.10.3.1\lib\net46\Telegram.Bot.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="libmp3lame.32.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="libmp3lame.64.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
99 changes: 99 additions & 0 deletions NoobDevBot(Stream)/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telegram.Bot;
using Telegram.Bot.Args;
using Telegram.Bot.Types;
using Telegram.Bot.Types.ReplyMarkups;
using System.Speech.Synthesis;
using System.Speech.AudioFormat;
using System.Media;
using System.IO;
using NAudio.Wave;
using NAudio.Lame;

namespace NoobDevBot
{
class Program
{
static TelegramBotClient bot;
static ReplyKeyboardMarkup markup;
static SpeechSynthesizer spsy;

static void Main(string[] args)
{
bot = new TelegramBotClient("232609616:AAGOJkDYQmSmUFhjToCt3JTtRnlWp3-TszE");
markup = new ReplyKeyboardMarkup();
spsy = new SpeechSynthesizer();

keyboard();
bot.OnMessage += bot_OnMessage;

bot.StartReceiving();





Console.ReadKey();
}

private static async void bot_OnMessage(object sender, MessageEventArgs e)
{
Console.WriteLine($"{e.Message.From.Username ?? e.Message.From.FirstName}: {e.Message.Text}");
switch (e.Message.Text)
{
case "/nextStream": await bot.SendTextMessageAsync(e.Message.Chat.Id, DateTime.UtcNow.ToLongDateString(), replyMarkup: markup); break;
case "/sayHello": await bot.SendTextMessageAsync(e.Message.Chat.Id, $"Hallo {e.Message.From.Username ?? e.Message.From.FirstName}", replyMarkup: markup); break;
case "/speakHello":

using (var stream = new MemoryStream())
{
using (var outStream = new MemoryStream())
{

string filename = e.Message.From.Username ?? e.Message.From.FirstName + ".mp3";
spsy.SetOutputToAudioStream(stream, new SpeechAudioFormatInfo(44100, AudioBitsPerSample.Sixteen, AudioChannel.Mono));

spsy.Speak($"Hallo {e.Message.From.Username ?? e.Message.From.FirstName}");
stream.Position = 0;
int seconds;
WaveFormat format = new WaveFormat(44100, 1);
using (var mp3file = new LameMP3FileWriter(outStream, format, 128))
{
stream.CopyTo(mp3file);
//((stream.Length) / (sampleRate * (bitRate / 8))) / channels
seconds = (int)(stream.Length / (44100 * 2)); //(int)wavefile.CurrentTime.TotalSeconds;
}

outStream.Position = 0;
FileToSend fts = new FileToSend("Hello.mp3", outStream);

await bot.SendAudioAsync(e.Message.Chat.Id, fts, seconds, "Cortana", "Hallo");

}
}
break;
default: await bot.SendTextMessageAsync(e.Message.Chat.Id, "I don't know, what do to with this command. Plase be so kind to use the keyboard, so you don't enter the wrong commands. Thank you very much.", replyMarkup: markup); break;
}

}

private static void keyboard()
{
var button00 = new KeyboardButton();
button00.Text = "/sayHello";
var button01 = new KeyboardButton();
button01.Text = "/nextStream";
var button02 = new KeyboardButton();
button02.Text = "/speakHello";
markup.Keyboard = new KeyboardButton[1][];
markup.Keyboard[0] = new KeyboardButton[3];
markup.Keyboard[0][0] = button00;
markup.Keyboard[0][1] = button01;
markup.Keyboard[0][2] = button02;
}
}
}
36 changes: 36 additions & 0 deletions NoobDevBot(Stream)/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("NoobDevBot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoobDevBot")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]

// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("27a6e8b1-f7c7-4cb7-ae69-e240ed7d9971")]

// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
8 changes: 8 additions & 0 deletions NoobDevBot(Stream)/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net46" />
<package id="NAudio" version="1.7.3" targetFramework="net46" />
<package id="NAudio.Lame" version="1.0.4" targetFramework="net46" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net46" />
<package id="Telegram.Bot" version="10.3.1" targetFramework="net46" />
</packages>
8 changes: 7 additions & 1 deletion NoobDevBot.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoobDevBot", "NoobDevBot\NoobDevBot.csproj", "{27A6E8B1-F7C7-4CB7-AE69-E240ED7D9971}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoobDevBot(Stream)", "NoobDevBot(Stream)\NoobDevBot(Stream).csproj", "{27A6E8B1-F7C7-4CB7-AE69-E240ED7D9971}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoobDevBot", "NoobDevBot\NoobDevBot.csproj", "{8CD55321-6BE8-4958-864F-64749D0008A5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,6 +17,10 @@ Global
{27A6E8B1-F7C7-4CB7-AE69-E240ED7D9971}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27A6E8B1-F7C7-4CB7-AE69-E240ED7D9971}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27A6E8B1-F7C7-4CB7-AE69-E240ED7D9971}.Release|Any CPU.Build.0 = Release|Any CPU
{8CD55321-6BE8-4958-864F-64749D0008A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8CD55321-6BE8-4958-864F-64749D0008A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8CD55321-6BE8-4958-864F-64749D0008A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CD55321-6BE8-4958-864F-64749D0008A5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
10 changes: 9 additions & 1 deletion NoobDevBot/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
32 changes: 31 additions & 1 deletion NoobDevBot/NoobDevBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{27A6E8B1-F7C7-4CB7-AE69-E240ED7D9971}</ProjectGuid>
<ProjectGuid>{8CD55321-6BE8-4958-864F-64749D0008A5}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NoobDevBot</RootNamespace>
Expand Down Expand Up @@ -33,21 +33,51 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="NAudio, Version=1.7.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NAudio.1.7.3\lib\net35\NAudio.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NAudio.Lame, Version=1.0.3.3048, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NAudio.Lame.1.0.4\lib\net20\NAudio.Lame.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Telegram.Bot, Version=10.3.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Telegram.Bot.10.3.1\lib\net46\Telegram.Bot.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="libmp3lame.32.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="libmp3lame.64.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
2 changes: 1 addition & 1 deletion NoobDevBot/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[assembly: ComVisible(false)]

// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("27a6e8b1-f7c7-4cb7-ae69-e240ed7d9971")]
[assembly: Guid("8cd55321-6be8-4958-864f-64749d0008a5")]

// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
Expand Down
8 changes: 8 additions & 0 deletions NoobDevBot/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net46" />
<package id="NAudio" version="1.7.3" targetFramework="net46" />
<package id="NAudio.Lame" version="1.0.4" targetFramework="net46" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net46" />
<package id="Telegram.Bot" version="10.3.1" targetFramework="net46" />
</packages>

0 comments on commit 62a12c6

Please sign in to comment.