mirror of
https://github.com/Jetsparrow/karmabot.git
synced 2026-04-26 06:05:05 +03:00
Compare commits
No commits in common. "bd2859913f27b8388a55a4995d6ddbf97d87f8d3" and "2cc286ad9cc6cbf56748c60a7c0b21336aafd740" have entirely different histories.
bd2859913f
...
2cc286ad9c
@ -12,7 +12,15 @@ public class Config : ConfigBase
|
||||
public string ApiKey { get; private set; }
|
||||
public string ConnectionString { get; private set; }
|
||||
|
||||
public string Proxy { get; private set; }
|
||||
public class ProxySettings
|
||||
{
|
||||
public string Url { get; private set; }
|
||||
public int Port { get; private set; }
|
||||
public string Login { get; private set; }
|
||||
public string Password { get; private set; }
|
||||
}
|
||||
|
||||
public ProxySettings Proxy { get; private set; }
|
||||
public class TimeoutConfig
|
||||
{
|
||||
public int DebtLimitSeconds { get; private set; } = 60 * 60 * 2;
|
||||
|
||||
@ -3,8 +3,7 @@ using JetKarmaBot.Models;
|
||||
using JetKarmaBot.Services;
|
||||
using JetKarmaBot.Services.Handling;
|
||||
using NLog;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Polling;
|
||||
using Telegram.Bot.Types;
|
||||
@ -33,17 +32,8 @@ public class JetKarmaBot : IDisposable
|
||||
{
|
||||
using (KarmaContext db = Db.GetContext())
|
||||
await db.Database.EnsureCreatedAsync();
|
||||
|
||||
var httpClientHandler = new HttpClientHandler();
|
||||
|
||||
if (Config.Proxy is string url)
|
||||
{
|
||||
httpClientHandler.Proxy = new WebProxy(url);
|
||||
httpClientHandler.UseProxy = true;
|
||||
}
|
||||
var httpClient = new HttpClient(httpClientHandler);
|
||||
|
||||
Client = new TelegramBotClient(Config.ApiKey, httpClient);
|
||||
|
||||
Client = new TelegramBotClient(Config.ApiKey);
|
||||
Container.AddInstance(Client);
|
||||
|
||||
timeoutWaitTaskToken = new CancellationTokenSource();
|
||||
@ -62,7 +52,7 @@ public class JetKarmaBot : IDisposable
|
||||
public async Task Stop()
|
||||
{
|
||||
if (stopped) return;
|
||||
Client?.Close();
|
||||
Client?.CloseAsync();
|
||||
timeoutWaitTaskToken?.Cancel();
|
||||
try
|
||||
{
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0" />
|
||||
<PackageReference Include="Telegram.Bot" Version="22.9.6" />
|
||||
<PackageReference Include="NLog" Version="6.1.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
|
||||
<PackageReference Include="Telegram.Bot" Version="22.0.2" />
|
||||
<PackageReference Include="NLog" Version="5.3.4" />
|
||||
<ProjectReference Include="..\perfusion\Perfusion\Perfusion.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@ -18,7 +18,7 @@ public class ChatCommandRouter : IRequestHandler
|
||||
|
||||
public async Task Start()
|
||||
{
|
||||
Me = await Client.GetMe();
|
||||
Me = await Client.GetMeAsync();
|
||||
}
|
||||
|
||||
public Task Handle(RequestContext ctx, Func<RequestContext, Task> next)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user