diff --git a/.gitignore b/.gitignore index 2b4db06..1a82a7d 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,6 @@ GuchiBot/bin/Debug/olduserph/ *.ide-shm *.vspx *.txt +GuchiBot/bin/Debug/voteslike.bot +*.bot +GuchiBot/bin/Debug/kek.jpg diff --git a/.vs/TelegramBots/v15/.suo b/.vs/TelegramBots/v15/.suo index c4bb9c8..3c8bdea 100644 Binary files a/.vs/TelegramBots/v15/.suo and b/.vs/TelegramBots/v15/.suo differ diff --git a/GuchiBot/Forms/Main.cs b/GuchiBot/Forms/Main.cs index ea74393..5de8d1a 100644 --- a/GuchiBot/Forms/Main.cs +++ b/GuchiBot/Forms/Main.cs @@ -87,6 +87,8 @@ public Main() Bot.SynkCommands.Add(Bot.GetModule()._Otvetka); Bot.SynkCommands.Add(Bot.GetModule()._SayAfterMe); Bot.SynkCommands.Add(Bot.GetModule()._GVoice); + Bot.SynkCommands.Add(Bot.GetModule()._BossOfTheGym); + Bot.SynkCommands.Add(Bot.GetModule()._BossOfTheGymSide); //Bot.SynkCommands.Add(Bot.GetModule()._ActiveUsersMosaic); Bot.SynkCommands.Add(new SynkCommand(new WebmModule().WebmFuncForBot, new List() { @@ -159,6 +161,7 @@ public Main() Bot.GetModule().SaveActions.Add(Bot.GetModule().Save); Bot.GetModule().SaveActions.Add(Bot.GetModule().Save); + Bot.GetModule().SaveActions.Add(Bot.GetModule().SaveBosses); Bot.Start(); } diff --git a/GuchiBot/bin/Debug/FunFunc/Who/WhoTitles/main25.png b/GuchiBot/bin/Debug/FunFunc/Who/WhoTitles/main25.png new file mode 100644 index 0000000..9bc5996 Binary files /dev/null and b/GuchiBot/bin/Debug/FunFunc/Who/WhoTitles/main25.png differ diff --git a/GuchiBot/bin/Debug/FunFunc/Who/WhoTitles/main26.png b/GuchiBot/bin/Debug/FunFunc/Who/WhoTitles/main26.png new file mode 100644 index 0000000..c1028d8 Binary files /dev/null and b/GuchiBot/bin/Debug/FunFunc/Who/WhoTitles/main26.png differ diff --git a/GuchiBot/bin/Debug/GuchiBot.exe b/GuchiBot/bin/Debug/GuchiBot.exe index 3a8a411..17711b2 100644 Binary files a/GuchiBot/bin/Debug/GuchiBot.exe and b/GuchiBot/bin/Debug/GuchiBot.exe differ diff --git a/GuchiBot/bin/Debug/GuchiBot.pdb b/GuchiBot/bin/Debug/GuchiBot.pdb index de21c67..334d80d 100644 Binary files a/GuchiBot/bin/Debug/GuchiBot.pdb and b/GuchiBot/bin/Debug/GuchiBot.pdb differ diff --git a/GuchiBot/bin/Debug/Modules/FunFunc/FunRes.Designer.cs b/GuchiBot/bin/Debug/Modules/FunFunc/FunRes.Designer.cs index b74fc83..e58ec81 100644 --- a/GuchiBot/bin/Debug/Modules/FunFunc/FunRes.Designer.cs +++ b/GuchiBot/bin/Debug/Modules/FunFunc/FunRes.Designer.cs @@ -69,5 +69,15 @@ internal static System.Drawing.Bitmap bomg { return ((System.Drawing.Bitmap)(obj)); } } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap boss { + get { + object obj = ResourceManager.GetObject("boss", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/GuchiBot/bin/Debug/Modules/FunFunc/FunRes.resx b/GuchiBot/bin/Debug/Modules/FunFunc/FunRes.resx index fbb4f3b..34736c8 100644 --- a/GuchiBot/bin/Debug/Modules/FunFunc/FunRes.resx +++ b/GuchiBot/bin/Debug/Modules/FunFunc/FunRes.resx @@ -121,4 +121,7 @@ ..\..\Resources\bomg.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\..\Resources\boss.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/GuchiBot/bin/Debug/Pes7BotCrator.dll b/GuchiBot/bin/Debug/Pes7BotCrator.dll index 66eb5ac..51b0929 100644 Binary files a/GuchiBot/bin/Debug/Pes7BotCrator.dll and b/GuchiBot/bin/Debug/Pes7BotCrator.dll differ diff --git a/GuchiBot/bin/Debug/Pes7BotCrator.pdb b/GuchiBot/bin/Debug/Pes7BotCrator.pdb index 5e543ff..86dc2d5 100644 Binary files a/GuchiBot/bin/Debug/Pes7BotCrator.pdb and b/GuchiBot/bin/Debug/Pes7BotCrator.pdb differ diff --git a/GuchiBot/bin/Debug/boss.png b/GuchiBot/bin/Debug/boss.png new file mode 100644 index 0000000..384e85d Binary files /dev/null and b/GuchiBot/bin/Debug/boss.png differ diff --git a/GuchiBot/bin/Debug/kek.jpg b/GuchiBot/bin/Debug/kek.jpg index 901bc02..9ee792d 100644 Binary files a/GuchiBot/bin/Debug/kek.jpg and b/GuchiBot/bin/Debug/kek.jpg differ diff --git a/GuchiBot/bin/Debug/votes.bot b/GuchiBot/bin/Debug/votes.bot index 1af12ce..f1b8c8d 100644 Binary files a/GuchiBot/bin/Debug/votes.bot and b/GuchiBot/bin/Debug/votes.bot differ diff --git a/GuchiBot/bin/Debug/voteslike.bot b/GuchiBot/bin/Debug/voteslike.bot index 6ce9922..be68175 100644 Binary files a/GuchiBot/bin/Debug/voteslike.bot and b/GuchiBot/bin/Debug/voteslike.bot differ diff --git a/GuchiBot/obj/Debug/GuchiBot.csprojAssemblyReference.cache b/GuchiBot/obj/Debug/GuchiBot.csprojAssemblyReference.cache index b30d6e0..f3b6b5c 100644 Binary files a/GuchiBot/obj/Debug/GuchiBot.csprojAssemblyReference.cache and b/GuchiBot/obj/Debug/GuchiBot.csprojAssemblyReference.cache differ diff --git a/GuchiBot/obj/Debug/GuchiBot.exe b/GuchiBot/obj/Debug/GuchiBot.exe index 3a8a411..17711b2 100644 Binary files a/GuchiBot/obj/Debug/GuchiBot.exe and b/GuchiBot/obj/Debug/GuchiBot.exe differ diff --git a/GuchiBot/obj/Debug/GuchiBot.pdb b/GuchiBot/obj/Debug/GuchiBot.pdb index de21c67..334d80d 100644 Binary files a/GuchiBot/obj/Debug/GuchiBot.pdb and b/GuchiBot/obj/Debug/GuchiBot.pdb differ diff --git a/Pes7BotCrator/Modules/FunFunc/FunFunc.cs b/Pes7BotCrator/Modules/FunFunc/FunFunc.cs index 9b8e7fc..7638dd9 100644 --- a/Pes7BotCrator/Modules/FunFunc/FunFunc.cs +++ b/Pes7BotCrator/Modules/FunFunc/FunFunc.cs @@ -17,6 +17,7 @@ namespace Pes7BotCrator.Modules.FunFunc { public class FunFunc : Module { + public List Bosses { get; set; } public InfTrue _CommandInf { set; get; } public ElseElse _CommandElse { get; set; } public GuchiName _CommandGuchi { get; set; } @@ -28,10 +29,13 @@ public class FunFunc : Module public Otvetka _Otvetka { get; set; } public ActiveUsersMosaic _ActiveUsersMosaic { get; set; } public Random Rand { get; set; } + public BossOfTheGym _BossOfTheGym { get; set; } + public BossOfTheGymSide _BossOfTheGymSide { get; set; } public string FaceImageDir { get; set; } public string WhoTitles { get; set; } public string WhoAnswers { get; set; } public string Triggers { get; set; } + public string FileNameBoss = "Bosses.bot"; public FunFunc(string imageDir = null, string whoTitles = null, string whoAnswers = null, string trigger = null) : base("FunFunc", typeof(FunFunc)) { _CommandInf = new InfTrue(); @@ -44,6 +48,8 @@ public FunFunc(string imageDir = null, string whoTitles = null, string whoAnswer _DvachRoll = new DvachRoll(); _ChtoEto = new ChtoEto(); _Otvetka = new Otvetka(); + _BossOfTheGym = new BossOfTheGym(); + _BossOfTheGymSide = new BossOfTheGymSide(); WhoTitles = whoTitles; WhoAnswers = whoAnswers; FaceImageDir = imageDir; @@ -51,6 +57,10 @@ public FunFunc(string imageDir = null, string whoTitles = null, string whoAnswer if (Directory.Exists("FunPics")) Directory.CreateDirectory("FunPics"); Rand = new Random(); + if (System.IO.File.Exists(FileNameBoss)) + Bosses = LoadBosses(); + else + Bosses = new List(); } public class InfTrue : SynkCommand { @@ -93,6 +103,104 @@ public class ChtoEto : SynkCommand { public ChtoEto() : base(ChtoAct, new List() { "/chto" }, commandName: "расскажи", descr: "Гачи найдёт информацию в гугле. Параметры: text, photo или video", clearcommand:false) { } } + public class BossOfTheGym : SynkCommand + { + public BossOfTheGym() : base(BossOfTheGymAct, new List() { "/bossclaim" }, commandName: "захват", descr: "Кто же бос этой качалки?", clearcommand: false) { } + } + public class BossOfTheGymSide : SynkCommand + { + public BossOfTheGymSide() : base(BossOfTheGymActRegistration, new List() { "/boss" }, commandName: "босс", descr: "Сражаться за ринг.", clearcommand: false) { } + } + + private List LoadBosses() + { + return SaveLoadModule.LoadSomething>(FileNameBoss); + } + + public void SaveBosses() + { + var ls = Bosses; + SaveLoadModule.SaveSomething(ls, FileNameBoss); + } + + public static void BossOfTheGymActRegistration(Message re, IBot Parent, List args) + { + if (re != null) + { + var fun = Parent.GetModule(); + var u = fun.Bosses.Find(fn => UserM.usernameGet(fn.GetUser()).Equals(UserM.usernameGet(re.From))); + if (u != null) + { + if (u.FromChat.Exists(f => f == re.Chat.Id)) + Parent.Client.SendTextMessageAsync(re.Chat.Id, $"Ты уже и так не ринге @{UserM.usernameGet(re.From)}!"); + else + { + u.FromChat.Add(re.Chat.Id); + Parent.Client.SendTextMessageAsync(re.Chat.Id, $"Добро пожаловать на ринг @{UserM.usernameGet(re.From)}!"); + } + } + else + { + Parent.Client.SendTextMessageAsync(re.Chat.Id, $"Добро пожаловать на ринг @{UserM.usernameGet(re.From)}!"); + var us = new UserM(re.From); + us.FromChat.Add(re.Chat.Id); + fun.Bosses.Add(new UserSerializable(us)); + fun.SaveBosses(); + } + } + } + + public static void BossOfTheGymAct(Message re, IBot Parent, List args) + { + if (re != null) + { + string path = $"Boss_{re.Chat.Id}.bot"; + TimeSpan timeLoss = new TimeSpan(24); + string name = null; + var fun = Parent.GetModule(); + var now_Time = DateTime.Now; + var id = re.Chat.Id; + bool AssWeCan = false; + if (System.IO.File.Exists(path)) + { + var strings = System.IO.File.ReadAllText(path); + var split = strings.Split('|'); + name = split[0]; + string time = split[1]; + var old = DateTime.Parse(time); + var timeLosser = now_Time - old; + timeLoss = new TimeSpan(24, 0, 0) - timeLosser; + if (timeLoss.TotalMinutes < 0) + AssWeCan = true; + } + else AssWeCan = true; + var usersFromThisChat = fun.Bosses.FindAll(fn => fn.FromChat.Any(g => g == id)); + if (AssWeCan && usersFromThisChat.Count > 0) + { + + System.IO.File.Delete(path); + Parent.Client.SendTextMessageAsync(id,"Ринг разрывется бурными овациями"); + Thread.Sleep(1000); + Parent.Client.SendTextMessageAsync(id, "Все гачимены выходят на ринг"); + Thread.Sleep(1000); + Parent.Client.SendTextMessageAsync(id, "Кто же на этот раз останеться с порваным очком"); + Thread.Sleep(1000); + Parent.Client.SendTextMessageAsync(id, "БОЙ!!!"); + Thread.Sleep(2000); + var winner = usersFromThisChat[Parent.Rand.Next(0, usersFromThisChat.Count)]; + Parent.Client.SendPhotoAsync(re.Chat.Id, new Telegram.Bot.Types.InputFiles.InputOnlineFile(System.IO.File.Open("boss.png", FileMode.Open), "boss")); + Thread.Sleep(500); + Parent.Client.SendTextMessageAsync(id, $"Поздравте этого LezerBOY: @{UserM.usernameGet(winner.GetUser())}, теперь он обладатель титула \"Бездонная Дыра\" и абсолютный чемпион качалки на сегодняшний день."); + var file = System.IO.File.Create(path); + file.Close(); + System.IO.File.WriteAllText(path, $"{UserM.nameGet(winner.GetUser())}|{now_Time}"); + } + else + { + Parent.Client.SendTextMessageAsync(re.Chat.Id, $"Энене, Босс качалки уже предопределён: {name} и будет им на протяжении {timeLoss.TotalHours} часов и {timeLoss.Minutes} минут."); + } + } + } public static void ActTrig(Update up, IBot Parent, List args) { diff --git a/Pes7BotCrator/Modules/FunFunc/FunRes.Designer.cs b/Pes7BotCrator/Modules/FunFunc/FunRes.Designer.cs index b74fc83..e58ec81 100644 --- a/Pes7BotCrator/Modules/FunFunc/FunRes.Designer.cs +++ b/Pes7BotCrator/Modules/FunFunc/FunRes.Designer.cs @@ -69,5 +69,15 @@ internal static System.Drawing.Bitmap bomg { return ((System.Drawing.Bitmap)(obj)); } } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap boss { + get { + object obj = ResourceManager.GetObject("boss", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/Pes7BotCrator/Modules/FunFunc/FunRes.resx b/Pes7BotCrator/Modules/FunFunc/FunRes.resx index fbb4f3b..34736c8 100644 --- a/Pes7BotCrator/Modules/FunFunc/FunRes.resx +++ b/Pes7BotCrator/Modules/FunFunc/FunRes.resx @@ -121,4 +121,7 @@ ..\..\Resources\bomg.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\..\Resources\boss.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Pes7BotCrator/Modules/SaveLoadModule.cs b/Pes7BotCrator/Modules/SaveLoadModule.cs index bd2ae64..4164427 100644 --- a/Pes7BotCrator/Modules/SaveLoadModule.cs +++ b/Pes7BotCrator/Modules/SaveLoadModule.cs @@ -67,12 +67,17 @@ public void backupIt() var i = DateTime.UtcNow.ToString().Split(' '); var j = Path.GetFileName(file); var k = $"./BackUp/{String.Join("_",i[0].Split('.'))}_{String.Join("_", i[1].Split(':'))}_{j}"; - File.Copy(file,$"{k}"); + try + { + File.Copy(file, $"{k}"); + } + catch { } } } public void saveIt() { + backupIt(); foreach (var act in SaveActions) { act.DynamicInvoke(); diff --git a/Pes7BotCrator/Pes7BotCrator.csproj b/Pes7BotCrator/Pes7BotCrator.csproj index 883f5d5..84f9d42 100644 --- a/Pes7BotCrator/Pes7BotCrator.csproj +++ b/Pes7BotCrator/Pes7BotCrator.csproj @@ -101,6 +101,7 @@ + @@ -117,6 +118,7 @@ +