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

Commit

Permalink
Merge branch 'release/Version_0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gallimathias committed Aug 17, 2016
2 parents aaa6374 + 2333528 commit ddbcb72
Show file tree
Hide file tree
Showing 20 changed files with 108 additions and 295 deletions.
14 changes: 0 additions & 14 deletions NoobDevBot(Stream)/App.config

This file was deleted.

91 changes: 0 additions & 91 deletions NoobDevBot(Stream)/NoobDevBot(Stream).csproj

This file was deleted.

99 changes: 0 additions & 99 deletions NoobDevBot(Stream)/Program.cs

This file was deleted.

36 changes: 0 additions & 36 deletions NoobDevBot(Stream)/Properties/AssemblyInfo.cs

This file was deleted.

Binary file removed NoobDevBot(Stream)/libmp3lame.32.dll
Binary file not shown.
Binary file removed NoobDevBot(Stream)/libmp3lame.64.dll
Binary file not shown.
8 changes: 0 additions & 8 deletions NoobDevBot(Stream)/packages.config

This file was deleted.

10 changes: 2 additions & 8 deletions NoobDevBot/App.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<connectionStrings>
<add name="NoobDevBot.Properties.Settings.NoobBotDatabaseConnectionString"
Expand All @@ -27,14 +27,8 @@
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
<remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
</system.data>
</configuration>
13 changes: 4 additions & 9 deletions NoobDevBot/CommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static class CommandManager
private static CommandHandler<MessageEventArgs, bool> commandHandler;
private static TelegramBotClient telegramBot;
private static ConcurrentDictionary<long, Func<MessageEventArgs, bool>> commandDictionary;

public static void Initialize(TelegramBotClient telegramBot)
{
commandHandler = new CommandHandler<MessageEventArgs, bool>();
Expand All @@ -34,6 +34,7 @@ public static bool Dispatch(string commandName, MessageEventArgs e)
{
if (commandName != null)
{
Logger.Log($"User: {e.Message.From.Username ?? e.Message.From.FirstName} try to use {commandName}");
Console.WriteLine($"User: {e.Message.From.Username ?? e.Message.From.FirstName} try to use {commandName}");
commandName = commandName.ToLower();

Expand Down Expand Up @@ -65,8 +66,7 @@ private static bool deleteStream(MessageEventArgs e)
}

var command = new DeleteStreamCommand(telegramBot, e.Message.Chat.Id);
if (!command.Dispatch(e))
return false;


command.FinishEvent += finishedCommand;

Expand All @@ -82,9 +82,7 @@ private static bool insertStream(MessageEventArgs e)
}

var command = new InsertStreamCommand(telegramBot, e.Message.Chat.Id);
if (!command.Dispatch(e))
return false;


command.FinishEvent += finishedCommand;

return commandDictionary.TryAdd(e.Message.Chat.Id, command.Dispatch);
Expand All @@ -93,10 +91,7 @@ private static bool insertStream(MessageEventArgs e)
private static bool nextStream(MessageEventArgs e)
{
var command = new NextStreamCommand(telegramBot, e.Message.Chat.Id);
if (!command.Dispatch(e))
return false;


return command.Dispatch(e);
}

Expand Down
2 changes: 2 additions & 0 deletions NoobDevBot/Commands/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class Command<TParameter, TOut>
{
public Func<TParameter, TOut> NextFunction { get; set; }

public bool Finished { get; protected set; }

public TOut Dispatch(TParameter parameter) => NextFunction(parameter);

public delegate void FinishEventHandler(object sender, TParameter e);
Expand Down
3 changes: 2 additions & 1 deletion NoobDevBot/Commands/HelloCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ public HelloCommand(TelegramBotClient telegramBot, long chatId)

public bool WriteHello(MessageEventArgs e)
{
Console.WriteLine($"{e.Message.From.Username ?? e.Message.From.FirstName}: {e.Message.Text}");
telegramBotClient.SendTextMessageAsync(id, $"Hallo {e.Message.From.Username ?? e.Message.From.FirstName}");

NextFunction = null;
RaiseFinishEvent(this, e);
Finished = true;
return true;
}
}
Expand Down
3 changes: 3 additions & 0 deletions NoobDevBot/Commands/InsertStreamCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ private void insertStream(MessageEventArgs e)
{
DatabaseManager.InsertNewStream(userId, date, streamTitle);
DatabaseManager.Submit();
DatabaseManager.GetNextStream();

AskUser("Dein Stream wurde erfolgreich eingetragen.");

RaiseFinishEvent(this, e);
NextFunction = null;
Finished = true;
}
}
}
Loading

0 comments on commit ddbcb72

Please sign in to comment.