Skip to content

Commit

Permalink
update 1.6.5
Browse files Browse the repository at this point in the history
New Fun Func, and some fixes. Added new type UserSerializable
  • Loading branch information
pes7 committed Sep 10, 2018
1 parent c587244 commit eaafd99
Show file tree
Hide file tree
Showing 37 changed files with 228 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ GuchiBot/bin/Debug/olduserph/
*.ide-shm
*.vspx
*.txt
GuchiBot/bin/Debug/voteslike.bot
*.bot
GuchiBot/bin/Debug/kek.jpg
Binary file modified .vs/TelegramBots/v15/.suo
Binary file not shown.
3 changes: 3 additions & 0 deletions GuchiBot/Forms/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public Main()
Bot.SynkCommands.Add(Bot.GetModule<FunFunc>()._Otvetka);
Bot.SynkCommands.Add(Bot.GetModule<TRM>()._SayAfterMe);
Bot.SynkCommands.Add(Bot.GetModule<GuchiVoice>()._GVoice);
Bot.SynkCommands.Add(Bot.GetModule<FunFunc>()._BossOfTheGym);
Bot.SynkCommands.Add(Bot.GetModule<FunFunc>()._BossOfTheGymSide);
//Bot.SynkCommands.Add(Bot.GetModule<FunFunc>()._ActiveUsersMosaic);
Bot.SynkCommands.Add(new SynkCommand(new WebmModule().WebmFuncForBot, new List<string>()
{
Expand Down Expand Up @@ -159,6 +161,7 @@ public Main()

Bot.GetModule<SaveLoadModule>().SaveActions.Add(Bot.GetModule<LikeDislikeModule>().Save);
Bot.GetModule<SaveLoadModule>().SaveActions.Add(Bot.GetModule<VoteModule>().Save);
Bot.GetModule<SaveLoadModule>().SaveActions.Add(Bot.GetModule<FunFunc>().SaveBosses);
Bot.Start();
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified GuchiBot/bin/Debug/GuchiBot.exe
Binary file not shown.
Binary file modified GuchiBot/bin/Debug/GuchiBot.pdb
Binary file not shown.
10 changes: 10 additions & 0 deletions GuchiBot/bin/Debug/Modules/FunFunc/FunRes.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions GuchiBot/bin/Debug/Modules/FunFunc/FunRes.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,7 @@
<data name="bomg" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\Resources\bomg.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="boss" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\Resources\boss.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file modified GuchiBot/bin/Debug/Pes7BotCrator.dll
Binary file not shown.
Binary file modified GuchiBot/bin/Debug/Pes7BotCrator.pdb
Binary file not shown.
Binary file added GuchiBot/bin/Debug/boss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified GuchiBot/bin/Debug/kek.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified GuchiBot/bin/Debug/votes.bot
Binary file not shown.
Binary file modified GuchiBot/bin/Debug/voteslike.bot
Binary file not shown.
Binary file modified GuchiBot/obj/Debug/GuchiBot.csprojAssemblyReference.cache
Binary file not shown.
Binary file modified GuchiBot/obj/Debug/GuchiBot.exe
Binary file not shown.
Binary file modified GuchiBot/obj/Debug/GuchiBot.pdb
Binary file not shown.
108 changes: 108 additions & 0 deletions Pes7BotCrator/Modules/FunFunc/FunFunc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Pes7BotCrator.Modules.FunFunc
{
public class FunFunc : Module
{
public List<UserSerializable> Bosses { get; set; }
public InfTrue _CommandInf { set; get; }
public ElseElse _CommandElse { get; set; }
public GuchiName _CommandGuchi { get; set; }
Expand All @@ -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();
Expand All @@ -44,13 +48,19 @@ 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;
Triggers = trigger;
if (Directory.Exists("FunPics"))
Directory.CreateDirectory("FunPics");
Rand = new Random();
if (System.IO.File.Exists(FileNameBoss))
Bosses = LoadBosses();
else
Bosses = new List<UserSerializable>();
}
public class InfTrue : SynkCommand
{
Expand Down Expand Up @@ -93,6 +103,104 @@ public class ChtoEto : SynkCommand
{
public ChtoEto() : base(ChtoAct, new List<string>() { "/chto" }, commandName: "расскажи", descr: "Гачи найдёт информацию в гугле. Параметры: text, photo или video", clearcommand:false) { }
}
public class BossOfTheGym : SynkCommand
{
public BossOfTheGym() : base(BossOfTheGymAct, new List<string>() { "/bossclaim" }, commandName: "захват", descr: "Кто же бос этой качалки?", clearcommand: false) { }
}
public class BossOfTheGymSide : SynkCommand
{
public BossOfTheGymSide() : base(BossOfTheGymActRegistration, new List<string>() { "/boss" }, commandName: "босс", descr: "Сражаться за ринг.", clearcommand: false) { }
}

private List<UserSerializable> LoadBosses()
{
return SaveLoadModule.LoadSomething<List<UserSerializable>>(FileNameBoss);
}

public void SaveBosses()
{
var ls = Bosses;
SaveLoadModule.SaveSomething(ls, FileNameBoss);
}

public static void BossOfTheGymActRegistration(Message re, IBot Parent, List<ArgC> args)
{
if (re != null)
{
var fun = Parent.GetModule<FunFunc>();
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<ArgC> args)
{
if (re != null)
{
string path = $"Boss_{re.Chat.Id}.bot";
TimeSpan timeLoss = new TimeSpan(24);
string name = null;
var fun = Parent.GetModule<FunFunc>();
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<ArgC> args)
{
Expand Down
10 changes: 10 additions & 0 deletions Pes7BotCrator/Modules/FunFunc/FunRes.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Pes7BotCrator/Modules/FunFunc/FunRes.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,7 @@
<data name="bomg" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\Resources\bomg.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="boss" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\Resources\boss.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
7 changes: 6 additions & 1 deletion Pes7BotCrator/Modules/SaveLoadModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions Pes7BotCrator/Pes7BotCrator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<Compile Include="Type\SynkCommand.cs" />
<Compile Include="Modules\2chModule\Types\ThBoard.cs" />
<Compile Include="Type\UserM.cs" />
<Compile Include="Type\UserSerializable.cs" />
<Compile Include="WebHook.cs" />
</ItemGroup>
<ItemGroup>
Expand All @@ -117,6 +118,7 @@
<ItemGroup />
<ItemGroup>
<Content Include="Resources\bomg.jpg" />
<Content Include="Resources\boss.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
Binary file added Pes7BotCrator/Resources/boss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion Pes7BotCrator/Type/UserM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public class UserM : User
{
public string PhotoPath { get; set; } = null;
public int MessageCount { get; set; }
public List<long> FromChat { get; set; }
public UserM(User us, int i = 0) : base()
{
this.FromChat = new List<long>();
this.Username = us.Username;
this.LastName = us.LastName;
this.Id = us.Id;
Expand Down Expand Up @@ -60,7 +62,9 @@ public static string nameGet(User us)
}
public static string usernameGet(User us)
{
return us.Username != null ? us.Username : $"{us.FirstName} {us.LastName}";
if(us!= null)
return us?.Username != null ? us.Username : $"{us.FirstName} {us.LastName}";
return null;
}
}
}
61 changes: 61 additions & 0 deletions Pes7BotCrator/Type/UserSerializable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telegram.Bot.Types;

namespace Pes7BotCrator.Type
{
[Serializable]
public class UserSerializable
{
public string PhotoPath { get; set; } = null;
public int MessageCount { get; set; }
public List<long> FromChat { get; set; }
public string Username { get; set; }
public string LastName { get; set; }
public int Id { get; set; }
public string FirstName { get; set; }
public UserSerializable(UserM us)
{
this.FromChat = us.FromChat;
this.Username = us.Username;
this.LastName = us.LastName;
this.Id = us.Id;
this.FirstName = us.FirstName;
this.PhotoPath = us.PhotoPath;
this.MessageCount = us.MessageCount;
}
public UserSerializable(User us)
{
this.FromChat = new List<long>();
this.Username = us.Username;
this.LastName = us.LastName;
this.Id = us.Id;
this.FirstName = us.FirstName;
}
public UserM GetUserM()
{
var user = new User();
user.Id = Id;
user.Username = Username;
user.FirstName = FirstName;
user.LastName = LastName;
var m = new UserM(user);
m.PhotoPath = PhotoPath;
m.MessageCount = MessageCount;
m.FromChat = FromChat;
return m;
}
public User GetUser()
{
var user = new User();
user.Id = Id;
user.Username = Username;
user.FirstName = FirstName;
user.LastName = LastName;
return user;
}
}
}
10 changes: 10 additions & 0 deletions Pes7BotCrator/bin/Debug/Modules/FunFunc/FunRes.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Pes7BotCrator/bin/Debug/Modules/FunFunc/FunRes.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,7 @@
<data name="bomg" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\Resources\bomg.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="boss" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\Resources\boss.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file modified Pes7BotCrator/bin/Debug/Pes7BotCrator.dll
Binary file not shown.
Binary file modified Pes7BotCrator/bin/Debug/Pes7BotCrator.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ad39361cfafcb55edc8aaaada4cc97b47f23ba5f
db3eb96273cebbf03566bf15fe6725b23916b965
Binary file not shown.
Binary file modified Pes7BotCrator/obj/Debug/Pes7BotCrator.dll
Binary file not shown.
Binary file modified Pes7BotCrator/obj/Debug/Pes7BotCrator.pdb
Binary file not shown.
Binary file not shown.

0 comments on commit eaafd99

Please sign in to comment.