Skip to content

Commit

Permalink
fixed Webpage support and added README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Space-Chemist committed Mar 5, 2021
1 parent dc5d88b commit 91c3e38
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
1 change: 1 addition & 0 deletions KothPlugin/KothPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="koth.html" />
<Content Include="README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
67 changes: 67 additions & 0 deletions KothPlugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Koth Plugin
> Adds Webpage, API, and Discord Webhook support for King of the Hill mod
![](https://cdn.discordapp.com/attachments/377619690513498133/406183455123177481/OpenSauce.svg)
![](https://cdn.discordapp.com/attachments/330777295952543744/478325842188042241/license.svg)
![](https://forthebadge.com/images/badges/60-percent-of-the-time-works-every-time.svg) ![](https://forthebadge.com/images/badges/built-with-love.svg)
[![Patreon](https://img.shields.io/badge/patreon-donate-green.svg)](https://www.patreon.com/bePatron?u=847269)

This is a Torch plugin for community servers using the the King Of the Hill Mod. It is mean to add functionality to the mod and the ability
to share score information with the community as well as being able to reset the the scores.

![](header.png)

## Installation

Torch Plugin

## Development setup

1. place the kothplugin zip in the Plugins folder
2. get the guid from the manifest in the Kothplugin zip. (also can be found at top of readme)
3. In the Torch.cfg place the guid inbetween the <plugins></plugins> tag.
4. launch torch and the plugin can be found in the plugins tab of torch.

##Use instructions

Using the plugin
* webserver enabled turns on the ability to use the API, Webhook, or webpage.
* The different features such as API, Webhook or webpage can each then be enabled seperately via their own checkboxes.
* Host is the IP you wish to host the API or webpage at.
* Port is the Port for the host.
* Webpage Url example "http://localhost:8888/koth"
* API Url example "http://localhost:8888/json"
* WebHook Url is for the discord Webhook Url.
* Message Prefix is the Prefix on the Discord message.
* Color is a hex code color for the webhook.
* EmbedTitle is the Title for the embed in Discord webhook.
* Clear Scores button clears save scores in scores.data
* Test webhook generates a test message for your webhook set up.
* Refresh Path changes the storage Path without restarting torch.
* update config saves the updates to the configuration of the plugin.

## Commands

* !koth clearscores - This clears koth scores
* !koth refreshpath - Used when changing Saved files but not relaunching torch
* !koth testwebhook - Sends a test message to Webhook


## Release History

* 1.0
* Initial Release
* 1.1.0
* Fix:`API Support` (Thanks @twistedgrim!)
* 0.1.2
* FIX: `WebPage Support`
* ADD: `README`

## Prerequisites

* Requires [Torch](https://torchapi.net/)


## License

This project is licensed under the AGPL-3.0 License - see the [LICENSE](LICENSE) file for details
2 changes: 1 addition & 1 deletion KothPlugin/WebService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace KothPlugin
internal static class WebService
{
private const string PageHtml =
"<!DOCTYPE html>\r\n<html lang=\"en\" ng-app=\"demoApp\">\r\n<head>\r\n\r\n <meta charset=\"utf-8\">\r\n <meta content=\"IE=edge\" http-equiv=\"X-UA-Compatible\">\r\n <meta content=\"width=device-width, initial-scale=1\" name=\"viewport\">\r\n <title>KOTH score Tracker</title>\r\n <link href=\"https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css\" rel=\"stylesheet\">\r\n <link href=\"https://fonts.googleapis.com/icon?family=Material+Icons\" rel=\"stylesheet\">\r\n <link href=\"https://rawgit.com/daniel-nagy/md-data-table/master/dist/md-data-table.css\" rel=\"stylesheet\">\r\n\r\n</head>\r\n\r\n<body layout=\"column\">\r\n\r\n<md-toolbar class=\"md-whiteframe-1dp\">\r\n <div class=\"md-toolbar-tools\">\r\n <div class=\"md-title\">KOTH score Tracker</div>\r\n </div>\r\n</md-toolbar>\r\n\r\n<md-content flex laout=\"column\" ng-controller=\"scoreController\">\r\n\r\n <md-card>\r\n\r\n <md-toolbar class=\"md-table-toolbar md-default\" ng-hide=\"options.rowSelection && selected.length\">\r\n <div class=\"md-toolbar-tools\">\r\n <span>KOTH</span>\r\n <div flex></div>\r\n <md-button class=\"md-icon-button\" ng-click=\"loadStuff()\">\r\n <md-icon>refresh</md-icon>\r\n </md-button>\r\n </div>\r\n </md-toolbar>\r\n\r\n <md-toolbar class=\"md-table-toolbar alternate\" ng-show=\"options.rowSelection && selected.length\">\r\n <div class=\"md-toolbar-tools\">\r\n <span>{{ selected.length }} {{ selected.length > 1 ? 'items' : 'item'}} selected</span>\r\n </div>\r\n </md-toolbar>\r\n\r\n <md-table-container>\r\n <table md-progress=\"promise\" md-row-select=\"options.rowSelection\" md-table\r\n multiple=\"{{ options.multiSelect }}\" ng-model=\"selected\">\r\n <thead md-head md-on-reorder=\"logOrder\" md-order=\"query.order\" ng-if=\"!options.decapitate\">\r\n <tr md-row>\r\n <th md-column md-order-by=\"Planet\"><span>Planet</span></th>\r\n <th md-column md-desc md-numeric md-order-by=\"FactionName\"><span>Faction</span></th>\r\n <th md-column md-numeric md-order-by=\"FactionTag\"><span>Tag</span></th>\r\n <th md-column md-numeric md-order-by=\"Points\"><span>Points</span></th>\r\n </tr>\r\n </thead>\r\n <tbody md-body>\r\n <tr md-auto-select=\"options.autoSelect\" md-on-select=\"logItem\" md-row md-select=\"score\"\r\n ng-disabled=\"score.FactionName > 400\"\r\n ng-repeat=\"score in scores.data | filter: filter.search | orderBy: query.order | limitTo: query.limit : (query.page -1) * query.limit\">\r\n <td md-cell>\r\n {{ score.PlanetId }}\r\n </td>\r\n <td md-cell>{{ score.FactionName }}</td>\r\n <td md-cell>{{ score.FactionTag }}</td>\r\n <td md-cell>{{ score.Points }}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n </md-table-container>\r\n\r\n <md-table-pagination md-boundary-links=\"options.boundaryLinks\" md-limit=\"query.limit\"\r\n md-limit-options=\"limitOptions\" md-on-paginate=\"logPagination\" md-page=\"query.page\"\r\n md-page-select=\"options.pageSelect\" md-total=\"{{ scores.count }}\"></md-table-pagination>\r\n </md-card>\r\n</md-content>\r\n\r\n<script src=\"https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js\"></script>\r\n<script src=\"https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js\"></script>\r\n<script src=\"https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js\"></script>\r\n<script src=\"https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js\"></script>\r\n<script src=\"https://rawgit.com/daniel-nagy/md-data-table/master/dist/md-data-table.js\"></script>\r\n<script>\r\n angular.module('demoApp', ['ngMaterial', 'md.data.table'])\r\n\r\n .config(['$mdThemingProvider', function ($mdThemingProvider) {\r\n 'use strict';\r\n\r\n $mdThemingProvider.theme('default')\r\n .primaryPalette('deep-purple');\r\n }])\r\n\r\n .controller('scoreController', ['$mdEditDialog', '$q', '$scope', '$http', '$timeout', function ($mdEditDialog, $q, $scope, $http, $timeout) {\r\n 'use strict';\r\n\r\n $scope.yes = REPLACEMEYES\r\n\r\n $scope.data = []\r\n $scope.data2 = []\r\n $scope.yes.WorldScores.map(m => m.WorldDescription).forEach(function (e) {\r\n e.map(d => d.Scores).forEach(function (l) {\r\n $scope.data.push(l.map(dd => dd.ScoreDescription)[0])\r\n })\r\n }\r\n )\r\n //$scope.data.map(m => m[0])\r\n $scope.data.forEach(m => m.map( mm => $scope.data2.push(mm)))\r\n $scope.scores = {\r\n \"count\": $scope.data2.length,\r\n \"data\": $scope.data2\r\n };\r\n\r\n console.log($scope.data2)\r\n $scope.selected = [];\r\n $scope.limitOptions = [5, 10, 15, 20, 50];\r\n\r\n $scope.options = {\r\n rowSelection: false,\r\n multiSelect: false,\r\n autoSelect: false,\r\n decapitate: false,\r\n largeEditDialog: false,\r\n boundaryLinks: false,\r\n limitSelect: true,\r\n pageSelect: true\r\n };\r\n\r\n $scope.query = {\r\n order: 'score',\r\n limit: 20,\r\n page: 1\r\n };\r\n\r\n }]);\r\n</script>\r\n</body>\r\n</html>\r\n";
"<!DOCTYPE html>\r\n<html lang=\"en\" ng-app=\"demoApp\">\r\n<head>\r\n\r\n <meta charset=\"utf-8\">\r\n <meta content=\"IE=edge\" http-equiv=\"X-UA-Compatible\">\r\n <meta content=\"width=device-width, initial-scale=1\" name=\"viewport\">\r\n <title>KOTH score Tracker</title>\r\n <link href=\"https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css\" rel=\"stylesheet\">\r\n <link href=\"https://fonts.googleapis.com/icon?family=Material+Icons\" rel=\"stylesheet\">\r\n <link href=\"https://rawgit.com/daniel-nagy/md-data-table/master/dist/md-data-table.css\" rel=\"stylesheet\">\r\n\r\n</head>\r\n\r\n<body layout=\"column\">\r\n\r\n<md-toolbar class=\"md-whiteframe-1dp\">\r\n <div class=\"md-toolbar-tools\">\r\n <div class=\"md-title\">KOTH score Tracker</div>\r\n </div>\r\n</md-toolbar>\r\n\r\n<md-content flex laout=\"column\" ng-controller=\"scoreController\">\r\n\r\n <md-card>\r\n\r\n <md-toolbar class=\"md-table-toolbar md-default\" ng-hide=\"options.rowSelection && selected.length\">\r\n <div class=\"md-toolbar-tools\">\r\n <span>KOTH</span>\r\n <div flex></div>\r\n <md-button class=\"md-icon-button\" ng-click=\"loadStuff()\">\r\n <md-icon>refresh</md-icon>\r\n </md-button>\r\n </div>\r\n </md-toolbar>\r\n\r\n <md-toolbar class=\"md-table-toolbar alternate\" ng-show=\"options.rowSelection && selected.length\">\r\n <div class=\"md-toolbar-tools\">\r\n <span>{{ selected.length }} {{ selected.length > 1 ? 'items' : 'item'}} selected</span>\r\n </div>\r\n </md-toolbar>\r\n\r\n <md-table-container>\r\n <table md-progress=\"promise\" md-row-select=\"options.rowSelection\" md-table\r\n multiple=\"{{ options.multiSelect }}\" ng-model=\"selected\">\r\n <thead md-head md-on-reorder=\"logOrder\" md-order=\"query.order\" ng-if=\"!options.decapitate\">\r\n <tr md-row>\r\n <th md-column md-order-by=\"Planet\"><span>Planet</span></th>\r\n <th md-column md-desc md-numeric md-order-by=\"FactionName\"><span>Faction</span></th>\r\n <th md-column md-numeric md-order-by=\"FactionTag\"><span>Tag</span></th>\r\n <th md-column md-numeric md-order-by=\"Points\"><span>Points</span></th>\r\n </tr>\r\n </thead>\r\n <tbody md-body>\r\n <tr md-auto-select=\"options.autoSelect\" md-on-select=\"logItem\" md-row md-select=\"score\"\r\n ng-disabled=\"score.FactionName > 400\"\r\n ng-repeat=\"score in scores.data | filter: filter.search | orderBy: query.order | limitTo: query.limit : (query.page -1) * query.limit\">\r\n <td md-cell>\r\n {{ score.PlanetId }}\r\n </td>\r\n <td md-cell>{{ score.FactionName }}</td>\r\n <td md-cell>{{ score.FactionTag }}</td>\r\n <td md-cell>{{ score.Points }}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n </md-table-container>\r\n\r\n <md-table-pagination md-boundary-links=\"options.boundaryLinks\" md-limit=\"query.limit\"\r\n md-limit-options=\"limitOptions\" md-on-paginate=\"logPagination\" md-page=\"query.page\"\r\n md-page-select=\"options.pageSelect\" md-total=\"{{ scores.count }}\"></md-table-pagination>\r\n </md-card>\r\n</md-content>\r\n\r\n<script src=\"https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js\"></script>\r\n<script src=\"https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js\"></script>\r\n<script src=\"https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js\"></script>\r\n<script src=\"https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js\"></script>\r\n<script src=\"https://rawgit.com/daniel-nagy/md-data-table/master/dist/md-data-table.js\"></script>\r\n<script>\r\n angular.module('demoApp', ['ngMaterial', 'md.data.table'])\r\n\r\n .config(['$mdThemingProvider', function ($mdThemingProvider) {\r\n 'use strict';\r\n\r\n $mdThemingProvider.theme('default')\r\n .primaryPalette('deep-purple');\r\n }])\r\n\r\n .controller('scoreController', ['$mdEditDialog', '$q', '$scope', '$http', '$timeout', function ($mdEditDialog, $q, $scope, $http, $timeout) {\r\n 'use strict';\r\n\r\n $scope.yes = REPLACEMEYES\r\n\r\n $scope.data = []\r\n $scope.data2 = []\r\n $scope.yes.PlanetScores.map(m => m.PlanetDescription).forEach(function (e) {\r\n e.map(d => d.Scores).forEach(function (l) {\r\n $scope.data.push(l.map(dd => dd.ScoreDescription)[0])\r\n })\r\n }\r\n )\r\n //$scope.data.map(m => m[0])\r\n $scope.data.forEach(m => m.map( mm => $scope.data2.push(mm)))\r\n $scope.scores = {\r\n \"count\": $scope.data2.length,\r\n \"data\": $scope.data2\r\n };\r\n\r\n console.log($scope.data2)\r\n $scope.selected = [];\r\n $scope.limitOptions = [5, 10, 15, 20, 50];\r\n\r\n $scope.options = {\r\n rowSelection: false,\r\n multiSelect: false,\r\n autoSelect: false,\r\n decapitate: false,\r\n largeEditDialog: false,\r\n boundaryLinks: false,\r\n limitSelect: true,\r\n pageSelect: true\r\n };\r\n\r\n $scope.query = {\r\n order: 'score',\r\n limit: 20,\r\n page: 1\r\n };\r\n\r\n }]);\r\n</script>\r\n</body>\r\n</html>\r\n";

private static readonly HttpListener Listener = new HttpListener
{Prefixes = {$"http://{Koth.Instance.Config.Host}:{Koth.Instance.Config.Port}/"}};
Expand Down

0 comments on commit 91c3e38

Please sign in to comment.