Skip to content

Commit

Permalink
Some work, lol
Browse files Browse the repository at this point in the history
  • Loading branch information
LaineZ committed Nov 2, 2024
1 parent 7febd9e commit 331a39c
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 120 deletions.
9 changes: 5 additions & 4 deletions fs24bot3/Commands/GenericCommandsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public sealed class GenericCommandsModule : ModuleBase<CommandProcessor.CustomCo
{
public CommandService Service { get; set; }



private string TrimTimezoneName(string name)
{
return name.Split(" ")[0];
Expand All @@ -35,15 +33,17 @@ private async Task HelpAll()
{
var cmds = Service.GetAllCommands();
string commandsOutput = "";
//string commandsOutput = Resources.help;
string styleOutput = "";
try
{
commandsOutput = File.ReadAllText("help.html");
styleOutput = File.ReadAllText("style.css");
}
catch (FileNotFoundException)
{
Log.Verbose("help.html not found, using compiled one");
Log.Verbose("help.html or style.css not found, using compiled one");
commandsOutput = Resources.help;
styleOutput = Resources.style;
}

var template = Handlebars.Compile(commandsOutput);
Expand All @@ -64,6 +64,7 @@ private async Task HelpAll()
});
var data = new
{
style = styleOutput,
commands = commandList,
customCommands = customCommands.Select(x => new
{
Expand Down
3 changes: 0 additions & 3 deletions fs24bot3/Commands/InternetCommandsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
using Genbox.WolframAlpha;
using HtmlAgilityPack;
using MCQuery;
using NetIRC;
using Newtonsoft.Json;
using Qmmands;
using Serilog;
using SQLite;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

Expand Down
16 changes: 14 additions & 2 deletions fs24bot3/Commands/InventoryCommandsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.IO;

namespace fs24bot3.Commands;

Expand Down Expand Up @@ -36,7 +37,7 @@ private async Task BuyOrSellInternal(string itemnamecount, bool sell = false)
if (success)
{
await Context.SendMessage(Context.Channel,
$"[green]Вы успешно {(sell ? "продали" : "купили")} {Context.BotCtx.Shop.Items[itemname].Name} x{count} за {price} денег");
$"[green]Вы успешно {(sell ? "продали" : "купили")} {Context.BotCtx.Shop.Items[itemname].Name} x{count} за {price} денег");
}
else
{
Expand Down Expand Up @@ -88,6 +89,17 @@ public async Task Tip(string destinationNick = "")
[Description("Магазин")]
public async Task Shop()
{
// TODO: Refactor to use templates
string shopTemplate = "";
string styleOutput = "";
try
{

}
catch (FileNotFoundException)
{

}
var shopitems = string.Join(' ',
Context.BotCtx.Shop.Items
.Where(x => x.Value.Sellable)
Expand Down Expand Up @@ -361,4 +373,4 @@ await Context.SendMessage(Context.Channel,
$"[red]Предмет {Context.BotCtx.Shop.Items[itemname].Name} использован!");
}
}
}
}
8 changes: 8 additions & 0 deletions fs24bot3/Properties/Resources.Designer.cs

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

5 changes: 4 additions & 1 deletion fs24bot3/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@
<data name="shop" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\shop.html;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;windows-1251</value>
</data>
<data name="style" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\style.css;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;windows-1251</value>
</data>
<data name="stopwords" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\stopwords.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
Expand All @@ -133,4 +136,4 @@
<data name="nouns" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\nouns.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>
</root>
52 changes: 6 additions & 46 deletions fs24bot3/Resources/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,17 @@
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>FS24BOT: Help</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<style>
body {
margin: 0px;
padding: 0px;
font-family: sans-serif;
color: #eff9d6;
background-color: #1b0326;
}

.menu {
background-color: rgb(37, 4, 53);
}

.menuItem {
padding-left: 1em;
padding-bottom: 0.5em;
display: inline-block;
}

.content {
margin: 0.5em;
padding: 5px;
padding-top: 10px;
}

.command {
border-bottom: 1px solid rgb(37, 4, 53);
}

.command-name {
font-family: "Iosevka Term Slab", "Consolas", monospace;
}

code {
background-color: #7a1c4b;
padding: 5px;
border-radius: 10px;
font-family: "Iosevka Slab", "Cascadia Mono", "Consolas", monospace;
}
</style>
<style>{{ style }}</style>
</head>

<body>
<div class="menu">
<header>
<div class="menuItem">
<h3>fs24bot help - список команд</h3>
</div>
</div>
</header>

<div class="content">
<header>
<p>Используйте <code>url:ссылка</code> в аргументе чтобы подставить результат из raw-url (pastebin, trashbin, gist и т.д)</p>
<div class="commands">
{{#each commands}}
Expand All @@ -78,8 +39,7 @@ <h3>Кастом команды:</h3>
</div>
{{/each}}
</div>
</div>
</div>
</header>
</body>

</html>
</html>
71 changes: 7 additions & 64 deletions fs24bot3/Resources/shop.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,19 @@
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>FS24BOT: Shop</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<style>
body {
margin: 0px;
padding: 0px;
}

a {
text-decoration: none;
color: #86796b;
}

h1 {
font-size: 70px;
}

a:hover {
color: #3A405A;
}

.menu {
background-color: #fbf1c7;
}

.menuItem {
padding-left: 1em;
padding-bottom: 0.5em;
display: inline-block;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}

.content {
margin: 0.5em;
padding: 5px;
padding-top: 10px;
font-family: Verdana, Geneva, Tahoma, sans-serif;
}

.feature-content {
display: flex;
flex-direction: row;
font-family: 'Alegreya Sans', 'sans-serif';
}

.feature-content p {
margin: 0;
}

.shopbox {
background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.3));
color: White;
width: 500px;
height: 20%;
padding: 25px;
margin: 5px;
border-radius: 5px;
font-family: Arial, Helvetica, sans-serif;
}
</style>
<style>{{ style }}</style>
</head>

<body>
<div class="menu">
<header>
<div class="menuItem">
<h3>fs24bot shop - МАГАЗИН</h3>
</div>
</div>
</header>

<div class="content">
[SHOPITEMS]
</div>
<main>
<!--- TODO: Shop content --->
</main>
</body>

</html>
</html>
38 changes: 38 additions & 0 deletions fs24bot3/Resources/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
body {
margin: 0px;
padding: 0px;
font-family: sans-serif;
color: #eff9d6;
background-color: #1b0326;
}

header {
background-color: rgb(37, 4, 53);
}

.menuItem {
padding-left: 1em;
padding-bottom: 0.5em;
display: inline-block;
}

main {
margin: 0.5em;
padding: 5px;
padding-top: 10px;
}

.command {
border-bottom: 1px solid rgb(37, 4, 53);
}

.command-name {
font-family: "Iosevka Term Slab", "Consolas", monospace;
}

code {
background-color: #7a1c4b;
padding: 5px;
border-radius: 10px;
font-family: "Iosevka Slab", "Cascadia Mono", "Consolas", monospace;
}

0 comments on commit 331a39c

Please sign in to comment.