Skip to content

Commit

Permalink
First Upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Gonzalo Moreno committed Sep 30, 2021
1 parent e9a30cc commit 9d0436a
Show file tree
Hide file tree
Showing 11 changed files with 880 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.vs
/BotPVU/obj
/BotPVU/bin
25 changes: 25 additions & 0 deletions BotPVU.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31624.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotPVU", "BotPVU\BotPVU.csproj", "{FC9552D2-506C-4BD5-B052-534E5F4AEF64}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FC9552D2-506C-4BD5-B052-534E5F4AEF64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC9552D2-506C-4BD5-B052-534E5F4AEF64}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC9552D2-506C-4BD5-B052-534E5F4AEF64}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC9552D2-506C-4BD5-B052-534E5F4AEF64}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {99910EDC-AED9-48EA-9D9A-BD7DE3F13418}
EndGlobalSection
EndGlobal
23 changes: 23 additions & 0 deletions BotPVU/BotPVU.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MailKit" Version="2.15.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.2" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
57 changes: 57 additions & 0 deletions BotPVU/MailHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MailKit.Net.Smtp;
using MailKit.Security;
using MimeKit;

namespace BotPVU
{
public static class MailHelper
{
public static void sendEmail(string Subject, string Body)
{
try
{
if (Models.Configuration.SendEmailNotification)
{
MimeMessage message = new MimeMessage();

MailboxAddress from = new MailboxAddress(Models.Configuration.SmtpUserName, Models.Configuration.SmtpUserName);
message.From.Add(from);
foreach (var item in Models.Configuration.NotificationEmails)
{
message.To.Add(new MailboxAddress("", item));
}

message.Priority = MessagePriority.Urgent;
message.Importance = MessageImportance.High;
message.Subject = Subject;
BodyBuilder bodyBuilder = new BodyBuilder();
bodyBuilder.HtmlBody = Body;
bodyBuilder.TextBody = Body;

message.Body = bodyBuilder.ToMessageBody();

SmtpClient client = new SmtpClient();
if (Models.Configuration.SmtpServerSSL)
client.Connect(Models.Configuration.SmtpServer, Models.Configuration.SmtpPort, SecureSocketOptions.StartTls);
else
client.Connect(Models.Configuration.SmtpServer, Models.Configuration.SmtpPort);

client.Authenticate(Models.Configuration.SmtpUserName, Models.Configuration.SmtpPassword);
client.Send(message);
client.Disconnect(true);
client.Dispose();
}
}
catch (Exception ex)
{
Console.WriteLine("ERROR EMAIL " + ex.Message + "\n" + ex.StackTrace);
}

}
}
}
20 changes: 20 additions & 0 deletions BotPVU/Models/Configuration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BotPVU.Models
{
public static class Configuration
{
public static string AuthPVUToken = "";
public static List<string> NotificationEmails = new List<string>();
public static bool SendEmailNotification = true;
public static string SmtpServer = "";
public static bool SmtpServerSSL = true;
public static int SmtpPort = 0;
public static string SmtpUserName = "";
public static string SmtpPassword = "";
}
}
185 changes: 185 additions & 0 deletions BotPVU/Models/PVU/PVUClasses.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BotPVU.Models.PVU
{
public class FarmConfig
{
public int le { get; set; }
public int hours { get; set; }
}

public class Stats
{
public string type { get; set; }
public int hp { get; set; }
public int defPhysics { get; set; }
public int defMagic { get; set; }
public int damagePhysics { get; set; }
public int damageMagic { get; set; }
public int damagePure { get; set; }
public double damageHpLoss { get; set; }
public int damageHpRemove { get; set; }
}

public class Synergy
{
public int requirement { get; set; }
public string description { get; set; }
}

public class Plant
{
public FarmConfig farmConfig { get; set; }
public Stats stats { get; set; }
public int type { get; set; }
public string iconUrl { get; set; }
public int rarity { get; set; }
public Synergy synergy { get; set; }
}

public class Elements
{
public int fire { get; set; }
public int water { get; set; }
public int ice { get; set; }
public int wind { get; set; }
public int electro { get; set; }
public int parasite { get; set; }
public int light { get; set; }
public int dark { get; set; }
public int metal { get; set; }
}

public class Capacity
{
public int plant { get; set; }
public int motherTree { get; set; }
}

public class Land
{
public Elements elements { get; set; }
public Capacity capacity { get; set; }
public int landId { get; set; }
public int x { get; set; }
public int y { get; set; }
public int totalOfElements { get; set; }
public int rarity { get; set; }
}

public class ActiveTool
{
public int count { get; set; }
public string _id { get; set; }
public int id { get; set; }
public string type { get; set; }
public int duration { get; set; }
public DateTime endTime { get; set; }
public DateTime startTime { get; set; }
}

public class Rate
{
public int le { get; set; }
public int hours { get; set; }
}

public class Datum
{
public string _id { get; set; }
public Plant plant { get; set; }
public Land land { get; set; }
public bool isTempPlant { get; set; }
public string stage { get; set; }
public string ownerId { get; set; }
public int landId { get; set; }
public long plantId { get; set; }
public int plantUnitId { get; set; }
public int plantType { get; set; }
public string plantElement { get; set; }
public List<ActiveTool> activeTools { get; set; }
public DateTime createdAt { get; set; }
public DateTime updatedAt { get; set; }
public int __v { get; set; }
public DateTime harvestTime { get; set; }
public Rate rate { get; set; }
public DateTime startTime { get; set; }
public bool hasSynergy { get; set; }
public bool needWater { get; set; }
public bool hasSeed { get; set; }
public DateTime? pausedTime { get; set; }
public bool inGreenhouse { get; set; }
public int count { get; set; }
public int totalHarvest { get; set; }
public int totalExtraHarvest { get; set; }
}

public class GetFarmResponse
{
public int status { get; set; }
public List<Datum> data { get; set; }
public int total { get; set; }
}


public class Token
{
public string challenge { get; set; }
public string seccode { get; set; }
public string validate { get; set; }
}

public class ApplyToolRequest
{
public string farmId { get; set; }
public int toolId { get; set; }
public Token token { get; set; }
}

public class Reward
{
public int type { get; set; }
public string name { get; set; }
public int target { get; set; }
public string status { get; set; }
}

public class DataWordTree
{
public int totalWater { get; set; }
public int level { get; set; }
public int myWater { get; set; }
public bool yesterdayReward { get; set; }
public bool rewardAvailable { get; set; }
public List<Reward> reward { get; set; }
}

public class WordTreeResponse
{
public int status { get; set; }
public DataWordTree data { get; set; }
}

public class BuySunFlowerRequest
{
public int amount { get; set; }
public int sunflowerId { get; set; }
}

public class DataBuySunFlower
{
public int quantity { get; set; }
public int sunflowerId { get; set; }
public string type { get; set; }
}

public class BuySunFlowerResponse
{
public int status { get; set; }
public DataBuySunFlower data { get; set; }
}
}
Loading

0 comments on commit 9d0436a

Please sign in to comment.