mirror of
https://github.com/Jetsparrow/karmabot.git
synced 2026-01-21 09:06:09 +03:00
Convert project to perfusion
This commit is contained in:
parent
58be680e4f
commit
36cb3d8fae
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "perfusion"]
|
||||||
|
path = perfusion
|
||||||
|
url = http://lserver1/git/perfusion.git
|
||||||
@ -1,9 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Dapper;
|
using Dapper;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
|
using Perfusion;
|
||||||
|
|
||||||
namespace JetKarmaBot
|
namespace JetKarmaBot
|
||||||
{
|
{
|
||||||
@ -105,7 +106,7 @@ namespace JetKarmaBot
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region service
|
#region service
|
||||||
public Db(Config cfg)
|
public Db([Inject(true)]Config cfg)
|
||||||
{
|
{
|
||||||
Log("Initializing...");
|
Log("Initializing...");
|
||||||
Conn = new MySqlConnection(cfg.ConnectionString);
|
Conn = new MySqlConnection(cfg.ConnectionString);
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using JetKarmaBot.Commands;
|
using JetKarmaBot.Commands;
|
||||||
|
using Perfusion;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -22,9 +23,8 @@ namespace JetKarmaBot
|
|||||||
client.SendTextMessageAsync(u.Value.ChatId, message);
|
client.SendTextMessageAsync(u.Value.ChatId, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JetKarmaBot(Config cfg, Db db)
|
public JetKarmaBot([Inject(true)]Config cfg)
|
||||||
{
|
{
|
||||||
this.db = db;
|
|
||||||
var httpProxy = new WebProxy($"{cfg.ProxyUrl}:{cfg.ProxyPort}")
|
var httpProxy = new WebProxy($"{cfg.ProxyUrl}:{cfg.ProxyPort}")
|
||||||
{
|
{
|
||||||
Credentials = new NetworkCredential(cfg.ProxyLogin, cfg.ProxyPassword)
|
Credentials = new NetworkCredential(cfg.ProxyLogin, cfg.ProxyPassword)
|
||||||
@ -46,8 +46,9 @@ namespace JetKarmaBot
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region service
|
#region service
|
||||||
Db db { get; }
|
[Inject(true)] Db db { get; set; }
|
||||||
TelegramBotClient client { get; }
|
TelegramBotClient client { get; }
|
||||||
|
[Inject(true)] Container container { get; set; }
|
||||||
User me { get; }
|
User me { get; }
|
||||||
|
|
||||||
ChatCommandRouter commands;
|
ChatCommandRouter commands;
|
||||||
@ -65,10 +66,10 @@ namespace JetKarmaBot
|
|||||||
void InitCommands()
|
void InitCommands()
|
||||||
{
|
{
|
||||||
commands = new ChatCommandRouter();
|
commands = new ChatCommandRouter();
|
||||||
commands.Add(new StartCommand(db));
|
commands.Add(container.ResolveObject(new StartCommand(db)));
|
||||||
commands.Add(new EchoCommand(client));
|
commands.Add(container.ResolveObject(new EchoCommand(client)));
|
||||||
commands.Add(new DefineCommand(client));
|
commands.Add(container.ResolveObject(new DefineCommand(client)));
|
||||||
commands.Add(new AwardCommand(db, client, me));
|
commands.Add(container.ResolveObject(new AwardCommand(db, client, me)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
<PackageReference Include="MySql.Data" Version="8.0.13" />
|
<PackageReference Include="MySql.Data" Version="8.0.13" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
||||||
<PackageReference Include="Telegram.Bot" Version="14.10.0" />
|
<PackageReference Include="Telegram.Bot" Version="14.10.0" />
|
||||||
|
<ProjectReference Include="..\perfusion\Perfusion\Perfusion.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using Perfusion;
|
||||||
|
|
||||||
namespace JetKarmaBot
|
namespace JetKarmaBot
|
||||||
{
|
{
|
||||||
@ -6,23 +7,20 @@ namespace JetKarmaBot
|
|||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Current = new App(new Config("karma.cfg.json"));
|
Container c = new Container();
|
||||||
|
c.AddInstance(new Config("karma.cfg.json"));
|
||||||
|
Current = c.GetInstance(typeof(App)) as App;
|
||||||
|
Current.Run();
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static App Current { get; private set; }
|
public static App Current { get; private set; }
|
||||||
|
|
||||||
public App(Config cfg)
|
public void Run()
|
||||||
{
|
{
|
||||||
Config = cfg;
|
|
||||||
Db = new Db(Config);
|
|
||||||
Watcher = new JetKarmaBot(Config, Db);
|
|
||||||
Console.WriteLine("JatKarmaBot started!");
|
Console.WriteLine("JatKarmaBot started!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Config Config { get; }
|
[Inject(true)] JetKarmaBot Watcher { get; }
|
||||||
Db Db { get; }
|
|
||||||
JetKarmaBot Watcher { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
perfusion
Submodule
1
perfusion
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit a9bd490c796b243245573ca4c9739a29364d2dde
|
||||||
Loading…
Reference in New Issue
Block a user