mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
chore: drop unused modules
These two are making lots of problems during update process: the `ChatQuotes` one was never operational and the `Destiny2.WhereIsXur` became obsolete, since Xur was granted his permanent place on the Tower
This commit is contained in:
@@ -7,13 +7,11 @@ COPY Kruzya.TelegramBot.sln ./
|
||||
COPY ./Core/*.csproj ./Core/
|
||||
COPY ./tests/*.csproj ./tests/
|
||||
COPY ./modules/CombotAntiSpam/*.csproj ./modules/CombotAntiSpam/
|
||||
COPY ./modules/Destiny2.WhereIsXur/*.csproj ./modules/Destiny2.WhereIsXur/
|
||||
COPY ./modules/RichSiteSummary/*.csproj ./modules/RichSiteSummary/
|
||||
COPY ./modules/UrlLimitations/*.csproj ./modules/UrlLimitations/
|
||||
COPY ./modules/ChatManagement/*.csproj ./modules/ChatManagement/
|
||||
COPY ./modules/Entertainment/*.csproj ./modules/Entertainment/
|
||||
COPY ./modules/UserGroupTag/*.csproj ./modules/UserGroupTag/
|
||||
COPY ./modules/ChatQuotes/*.csproj ./modules/ChatQuotes/
|
||||
COPY ./modules/Reputation/*.csproj ./modules/Reputation/
|
||||
COPY ./modules/ContentStore/*.csproj ./modules/ContentStore/
|
||||
COPY ./modules/DebugTools/*.csproj ./modules/DebugTools/
|
||||
|
||||
@@ -15,16 +15,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "tests\Tests.csproj
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UrlLimitations", "modules\UrlLimitations\UrlLimitations.csproj", "{B82E3339-3B34-4600-8C59-C5A3640B1982}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Destiny2.WhereIsXur", "modules\Destiny2.WhereIsXur\Destiny2.WhereIsXur.csproj", "{AE782132-BED8-4D1E-98FA-CB768171D332}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChatManagement", "modules\ChatManagement\ChatManagement.csproj", "{55ACF7F7-409A-45EE-A41D-D8417DE7EAA7}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UserGroupTag", "modules\UserGroupTag\UserGroupTag.csproj", "{5B89E22A-78CF-4037-BE0D-5F88EF47022B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entertainment", "modules\Entertainment\Entertainment.csproj", "{1D62101B-C2B1-4E79-8F7A-690E44E3EE81}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChatQuotes", "modules\ChatQuotes\ChatQuotes.csproj", "{04F16325-8F44-4250-9B2E-0F77E8F65CBF}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Reputation", "modules\Reputation\Reputation.csproj", "{03F3C7D5-6FEF-4A83-9191-501091BFC1AC}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ContentStore", "modules\ContentStore\ContentStore.csproj", "{4F1E8FE8-640F-4671-87FC-0FFCCB6EDF5E}"
|
||||
@@ -61,10 +57,6 @@ Global
|
||||
{B82E3339-3B34-4600-8C59-C5A3640B1982}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B82E3339-3B34-4600-8C59-C5A3640B1982}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B82E3339-3B34-4600-8C59-C5A3640B1982}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AE782132-BED8-4D1E-98FA-CB768171D332}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AE782132-BED8-4D1E-98FA-CB768171D332}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AE782132-BED8-4D1E-98FA-CB768171D332}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AE782132-BED8-4D1E-98FA-CB768171D332}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{55ACF7F7-409A-45EE-A41D-D8417DE7EAA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{55ACF7F7-409A-45EE-A41D-D8417DE7EAA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{55ACF7F7-409A-45EE-A41D-D8417DE7EAA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -77,10 +69,6 @@ Global
|
||||
{1D62101B-C2B1-4E79-8F7A-690E44E3EE81}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1D62101B-C2B1-4E79-8F7A-690E44E3EE81}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1D62101B-C2B1-4E79-8F7A-690E44E3EE81}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{04F16325-8F44-4250-9B2E-0F77E8F65CBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{04F16325-8F44-4250-9B2E-0F77E8F65CBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{04F16325-8F44-4250-9B2E-0F77E8F65CBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{04F16325-8F44-4250-9B2E-0F77E8F65CBF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{03F3C7D5-6FEF-4A83-9191-501091BFC1AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{03F3C7D5-6FEF-4A83-9191-501091BFC1AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{03F3C7D5-6FEF-4A83-9191-501091BFC1AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -109,11 +97,9 @@ Global
|
||||
{F1E1FBB7-ABA4-4304-9A42-D4975822B002} = {C7821F15-DEDD-474F-A575-A296D4B58F10}
|
||||
{C50D64C3-204B-4B58-927B-C8D759787252} = {C7821F15-DEDD-474F-A575-A296D4B58F10}
|
||||
{B82E3339-3B34-4600-8C59-C5A3640B1982} = {C7821F15-DEDD-474F-A575-A296D4B58F10}
|
||||
{AE782132-BED8-4D1E-98FA-CB768171D332} = {C7821F15-DEDD-474F-A575-A296D4B58F10}
|
||||
{55ACF7F7-409A-45EE-A41D-D8417DE7EAA7} = {C7821F15-DEDD-474F-A575-A296D4B58F10}
|
||||
{5B89E22A-78CF-4037-BE0D-5F88EF47022B} = {C7821F15-DEDD-474F-A575-A296D4B58F10}
|
||||
{1D62101B-C2B1-4E79-8F7A-690E44E3EE81} = {C7821F15-DEDD-474F-A575-A296D4B58F10}
|
||||
{04F16325-8F44-4250-9B2E-0F77E8F65CBF} = {C7821F15-DEDD-474F-A575-A296D4B58F10}
|
||||
{03F3C7D5-6FEF-4A83-9191-501091BFC1AC} = {C7821F15-DEDD-474F-A575-A296D4B58F10}
|
||||
{4F1E8FE8-640F-4671-87FC-0FFCCB6EDF5E} = {C7821F15-DEDD-474F-A575-A296D4B58F10}
|
||||
{B95C9180-4893-4A33-BF43-AB2EE998650C} = {C7821F15-DEDD-474F-A575-A296D4B58F10}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
using System.Globalization;
|
||||
using Kruzya.TelegramBot.Core;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using West.TelegramBot.ChatQuotes.Json;
|
||||
|
||||
namespace West.TelegramBot.ChatQuotes;
|
||||
|
||||
public class ChatQuotes : Module
|
||||
{
|
||||
public static readonly JsonSerializerSettings SerializerSettings = new()
|
||||
{
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
|
||||
DateParseHandling = DateParseHandling.None,
|
||||
Converters =
|
||||
{
|
||||
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal },
|
||||
new StringEnumConverter(new CamelCaseNamingStrategy())
|
||||
},
|
||||
ContractResolver = new NullToEmptyObjectResolver()
|
||||
};
|
||||
|
||||
public ChatQuotes(Core core) : base(core) { }
|
||||
|
||||
public override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<QuoteGeneratorService>();
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>West.TelegramBot.ChatQuotes</RootNamespace>
|
||||
<AssemblyName>TelegramBot.ChatQuotes</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Handler\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Core\Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Delete Files="$(OutDir)\TelegramBot.dll" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -1,38 +0,0 @@
|
||||
using BotFramework;
|
||||
using BotFramework.Attributes;
|
||||
using BotFramework.Enums;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace West.TelegramBot.ChatQuotes.Handler;
|
||||
|
||||
public class Quote : BotEventHandler
|
||||
{
|
||||
private readonly QuoteGeneratorService _quoteGenerator;
|
||||
|
||||
public Quote(QuoteGeneratorService quoteGenerator)
|
||||
{
|
||||
_quoteGenerator = quoteGenerator;
|
||||
}
|
||||
|
||||
[InChat(InChat.Public)]
|
||||
[Command("q", CommandParseMode.Both)]
|
||||
public async Task HandleQuote()
|
||||
{
|
||||
var msg = RawUpdate.Message;
|
||||
var replyToMessage = msg?.ReplyToMessage;
|
||||
if (msg == null || replyToMessage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var quoteImage = await _quoteGenerator.GenerateQuoteImage(replyToMessage);
|
||||
if (quoteImage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await Bot.SendStickerAsync(Chat.Id, new InputFile(quoteImage),
|
||||
replyToMessageId: msg.MessageId);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace West.TelegramBot.ChatQuotes.Json;
|
||||
|
||||
class NullToEmptyObjectResolver : DefaultContractResolver
|
||||
{
|
||||
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
|
||||
{
|
||||
return type.GetProperties()
|
||||
.Select(p => {
|
||||
var jp = base.CreateProperty(p, memberSerialization);
|
||||
jp.ValueProvider = new NullToEmptyObjectValueProvider(p);
|
||||
return jp;
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace West.TelegramBot.ChatQuotes.Json;
|
||||
|
||||
public class NullToEmptyObjectValueProvider : IValueProvider
|
||||
{
|
||||
private readonly PropertyInfo _memberInfo;
|
||||
public NullToEmptyObjectValueProvider(PropertyInfo memberInfo)
|
||||
{
|
||||
_memberInfo = memberInfo;
|
||||
}
|
||||
|
||||
public object? GetValue(object target)
|
||||
{
|
||||
var result = _memberInfo.GetValue(target);
|
||||
if (_memberInfo.PropertyType == typeof(Message) && result == null) result = new object();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void SetValue(object target, object? value)
|
||||
{
|
||||
_memberInfo.SetValue(target, value);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace West.TelegramBot.ChatQuotes.Model.Quote;
|
||||
|
||||
public enum MediaType
|
||||
{
|
||||
Sticker = 0
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using File = Telegram.Bot.Types.File;
|
||||
using TgUser = Telegram.Bot.Types.User;
|
||||
|
||||
namespace West.TelegramBot.ChatQuotes.Model.Quote;
|
||||
|
||||
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
|
||||
public class Message
|
||||
{
|
||||
public List<File>? Media { get; set; }
|
||||
public MediaType? MediaType { get; set; }
|
||||
public long ChatId { get; set; }
|
||||
public bool Avatar { get; set; } = true;
|
||||
public User? From { get; set; }
|
||||
public string? Text { get; set; }
|
||||
public Telegram.Bot.Types.Message? ReplyMessage { get; set; }
|
||||
|
||||
public static Message FromMessage(Telegram.Bot.Types.Message msg)
|
||||
{
|
||||
var quoteMessage = new Message();
|
||||
|
||||
if (msg.Text != null)
|
||||
{
|
||||
quoteMessage.Text = msg.Text;
|
||||
}
|
||||
|
||||
var sticker = msg.Sticker;
|
||||
if (sticker != null)
|
||||
{
|
||||
var file = new File
|
||||
{
|
||||
FileId = sticker.FileId,
|
||||
FileSize = sticker.FileSize,
|
||||
FileUniqueId = sticker.FileUniqueId
|
||||
};
|
||||
quoteMessage.Media = new List<File> { file };
|
||||
quoteMessage.MediaType = Quote.MediaType.Sticker;
|
||||
}
|
||||
|
||||
TgUser? user = null;
|
||||
if (msg.ForwardSenderName != null && msg.ForwardFrom == null)
|
||||
{
|
||||
user = new TgUser
|
||||
{
|
||||
FirstName = msg.ForwardSenderName
|
||||
};
|
||||
}
|
||||
|
||||
quoteMessage.ChatId = msg.From?.Id ?? msg.Chat.Id;
|
||||
quoteMessage.ReplyMessage = msg.ReplyToMessage;
|
||||
quoteMessage.From = User.FromTgUser(user ?? msg.ForwardFrom ?? msg.From!);
|
||||
|
||||
return quoteMessage;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
#nullable enable
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace West.TelegramBot.ChatQuotes.Model.Quote;
|
||||
|
||||
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
|
||||
public class Request
|
||||
{
|
||||
public Request(Telegram.Bot.Types.Message msg)
|
||||
{
|
||||
// TODO: move default values to config
|
||||
Format = "webp";
|
||||
BackgroundColor = "#1b1429";
|
||||
Width = 512;
|
||||
Height = 768;
|
||||
Scale = 2;
|
||||
|
||||
Messages = new List<Message> {Message.FromMessage(msg)};
|
||||
}
|
||||
|
||||
public Type Type { get; set; }
|
||||
public string Format { get; set; }
|
||||
public string BackgroundColor { get; set; }
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
public int Scale { get; set; }
|
||||
public List<Message>? Messages { get; set; }
|
||||
|
||||
public string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this, ChatQuotes.SerializerSettings);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#nullable disable
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace West.TelegramBot.ChatQuotes.Model.Quote;
|
||||
|
||||
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
|
||||
public class Response
|
||||
{
|
||||
public bool Ok { get; set; }
|
||||
|
||||
public Result Result { get; set; }
|
||||
public static Response FromJson(string json)
|
||||
=> JsonConvert.DeserializeObject<Response>(json, ChatQuotes.SerializerSettings);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace West.TelegramBot.ChatQuotes.Model.Quote;
|
||||
|
||||
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
|
||||
public class Result
|
||||
{
|
||||
public string Image { get; set; } = "";
|
||||
public Type Type { get; set; }
|
||||
public long Width { get; set; }
|
||||
public long Height { get; set; }
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace West.TelegramBot.ChatQuotes.Model.Quote;
|
||||
|
||||
public enum Type
|
||||
{
|
||||
Quote = 0,
|
||||
Image,
|
||||
Null
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace West.TelegramBot.ChatQuotes.Model;
|
||||
|
||||
public class User : Telegram.Bot.Types.User
|
||||
{
|
||||
[JsonProperty]
|
||||
public string Name => LastName != null ? $"{FirstName} {LastName}" : FirstName;
|
||||
|
||||
public static User FromTgUser(Telegram.Bot.Types.User user)
|
||||
{
|
||||
return new User
|
||||
{
|
||||
Id = user.Id,
|
||||
FirstName = user.FirstName,
|
||||
LastName = user.LastName,
|
||||
Username = user.Username,
|
||||
LanguageCode = user.LanguageCode,
|
||||
IsBot = user.IsBot
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using West.TelegramBot.ChatQuotes.Model.Quote;
|
||||
using Message = Telegram.Bot.Types.Message;
|
||||
|
||||
namespace West.TelegramBot.ChatQuotes;
|
||||
|
||||
public class QuoteGeneratorService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly MediaTypeHeaderValue _mediaType;
|
||||
|
||||
public QuoteGeneratorService(IConfiguration configuration)
|
||||
{
|
||||
_httpClient = new HttpClient
|
||||
{
|
||||
BaseAddress = new Uri(configuration.GetValue<string>("QuoteApiUrl"))
|
||||
};
|
||||
|
||||
_mediaType = MediaTypeHeaderValue.Parse("application/json");
|
||||
}
|
||||
|
||||
public async Task<Stream?> GenerateQuoteImage(Message msg)
|
||||
{
|
||||
var request = new Request(msg);
|
||||
var content = new ByteArrayContent(Encoding.UTF8.GetBytes(request.ToJson().ToCharArray()))
|
||||
{
|
||||
Headers =
|
||||
{
|
||||
ContentType = _mediaType
|
||||
}
|
||||
};
|
||||
|
||||
var resp = await _httpClient.PostAsync("/generate", content);
|
||||
var quoteResponse = JsonConvert.DeserializeObject<Response>(await resp.Content.ReadAsStringAsync());
|
||||
|
||||
return quoteResponse.Ok ? new MemoryStream(Convert.FromBase64String(quoteResponse.Result.Image)) : null;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<AssemblyName>TelegramBot.D2_WhereIsXur</AssemblyName>
|
||||
<RootNamespace>Kruzya.TelegramBot.Destiny2.WhereIsXur</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Core\Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Fizzler.Systems.HtmlAgilityPack" Version="1.2.1" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.39" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,9 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Kruzya.TelegramBot.Destiny2.WhereIsXur.Provider;
|
||||
|
||||
public interface IXurPlaceProvider
|
||||
{
|
||||
public Task<string> GetPlaceAsync();
|
||||
public string GetPlace();
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
using Fizzler.Systems.HtmlAgilityPack;
|
||||
using HtmlAgilityPack;
|
||||
|
||||
namespace Kruzya.TelegramBot.Destiny2.WhereIsXur.Provider;
|
||||
|
||||
public class XurWiki : IXurPlaceProvider
|
||||
{
|
||||
public async Task<string> GetPlaceAsync()
|
||||
{
|
||||
var web = new HtmlWeb();
|
||||
var document = await web.LoadFromWebAsync("https://xur.wiki");
|
||||
|
||||
var place = document.DocumentNode.QuerySelector(".location_name");
|
||||
if (place != null)
|
||||
{
|
||||
return place.InnerText.Trim();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public string GetPlace()
|
||||
{
|
||||
return GetPlaceAsync().GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
using BotFramework;
|
||||
using BotFramework.Attributes;
|
||||
using Kruzya.TelegramBot.Destiny2.WhereIsXur.Provider;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
|
||||
namespace Kruzya.TelegramBot.Destiny2.WhereIsXur;
|
||||
|
||||
public class RequestHandler : BotEventHandler
|
||||
{
|
||||
protected readonly IXurPlaceProvider _placeProvider;
|
||||
|
||||
public RequestHandler(IXurPlaceProvider xurPlaceProvider)
|
||||
{
|
||||
_placeProvider = xurPlaceProvider;
|
||||
}
|
||||
|
||||
[Command("d2_xur")]
|
||||
public async Task WhereIsXur()
|
||||
{
|
||||
var place = await _placeProvider.GetPlaceAsync();
|
||||
if (string.IsNullOrWhiteSpace(place))
|
||||
{
|
||||
await Response("unknown");
|
||||
return;
|
||||
}
|
||||
|
||||
await Response(place);
|
||||
}
|
||||
|
||||
protected async Task Response(string place)
|
||||
{
|
||||
await Bot.SendTextMessageAsync(Chat, $"<b>Xûr</b> place is <code>{place}</code>", parseMode: ParseMode.Html);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using Kruzya.TelegramBot.Core;
|
||||
using Kruzya.TelegramBot.Destiny2.WhereIsXur.Provider;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Kruzya.TelegramBot.Destiny2.WhereIsXur;
|
||||
|
||||
public class WhereIsXur : Module
|
||||
{
|
||||
public WhereIsXur(Core.Core core) : base(core)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<IXurPlaceProvider, XurWiki>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user