mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
[code-watcher] Add CodeWatcherMode option.
There are three option values:
- Disabled: module does nothing (wow).
- Remove: module removes matching messages and sends temporary message
to instruct user what to do.
- Upload: module uploads detected code to configured Haste Server.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using System.Net.Http.Json;
|
||||
using West.TelegramBot.CodeWatcher.Dto;
|
||||
|
||||
namespace West.TelegramBot.CodeWatcher.Service;
|
||||
|
||||
public class HasteService : IHasteService
|
||||
{
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public HasteService(HttpClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public async Task<HasteResponse> PostDocumentAsync(string data)
|
||||
{
|
||||
var response = await (await _client.PostAsync("documents", new StringContent(data)))
|
||||
.Content.ReadFromJsonAsync<HasteResponse>();
|
||||
|
||||
if (response == null)
|
||||
{
|
||||
throw new Exception("Haste returned some shit");
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public Uri GetHasteUri()
|
||||
{
|
||||
return _client.BaseAddress!;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user