This repository has been archived by the owner on Jan 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #5 Use message entities to find commands
- Loading branch information
Showing
13 changed files
with
94 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -246,3 +246,6 @@ ModelManifest.xml | |
|
||
# Settings for development time | ||
appsettings.*.json | ||
|
||
# Rider IDE | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,55 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.Options; | ||
using Telegram.Bot.Framework; | ||
using Telegram.Bot.Types; | ||
using Telegram.Bot.Types.Enums; | ||
|
||
namespace SampleEchoBot | ||
{ | ||
public class EchoBot : BotBase<EchoBot> | ||
{ | ||
public EchoBot(IOptions<BotOptions<EchoBot>> botOptions) | ||
private readonly ILogger<EchoBot> _logger; | ||
|
||
public EchoBot(IOptions<BotOptions<EchoBot>> botOptions, ILogger<EchoBot> logger) | ||
: base(botOptions) | ||
{ | ||
|
||
_logger = logger; | ||
} | ||
|
||
public override Task HandleUnknownMessage(Update update) | ||
public override async Task HandleUnknownUpdate(Update update) | ||
{ | ||
return Task.CompletedTask; | ||
_logger.LogWarning("Unable to handle update of type `{0}`", update.Type); | ||
|
||
string text; | ||
int replyToMesageId = default(int); | ||
|
||
switch (update.Type) | ||
{ | ||
case UpdateType.MessageUpdate when | ||
new[] {ChatType.Private, ChatType.Group, ChatType.Supergroup}.Contains(update.Message.Chat.Type): | ||
text = $"Unable to handle message update of type `{update.Message.Type}`."; | ||
replyToMesageId = update.Message.MessageId; | ||
break; | ||
default: | ||
text = null; | ||
break; | ||
} | ||
|
||
if (text != null) | ||
{ | ||
await Client.SendTextMessageAsync(update.Message.Chat.Id, text, ParseMode.Markdown, | ||
replyToMessageId: replyToMesageId); | ||
} | ||
} | ||
|
||
public override Task HandleFaultedUpdate(Update update, Exception e) | ||
{ | ||
_logger.LogError($"Exception occured in handling update of type `{0}`: {1}", update.Type, e.Message); | ||
|
||
return Task.CompletedTask; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters