osuka's votecounter + modtools

This forum is for discussion related to the game.
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

osuka's votecounter + modtools

Post Post #0 (isolation #0) » Sat May 06, 2023 2:22 pm

Post by osuka »

hi everyone

i love modding but i'm a lazy idiot, so naturally the obvious answer was to write a vote counter. I figured that could help other people who are still counting votes by hand, so I figured what the hell, tossed it on github. for now it's just a votecounter lol but in the future i might add more stuff to it, especially if there's demand for it.

osuka's modtools

available at https://github.com/fbastos1/mafiascum-m ... /tree/main pls dont dox me
votecounter

"but osuka, how is this different from all the other vote counters out there?" great question, thank you for asking.

most of the vote counters i've ever seen are web-based. This comes with a few downsides:
- it costs $$$ to run a server, so they probably won't run forever
- servers may have downtime
- servers may be overloaded, which could make the votecounter painfully slow

i've seen some vote counters that are not hosted on a server but instead a downloadable executable. that's cool too, but it does also come with a few downsides:
- platform support may be limited (what if it's a windows binary, but i'm on macOS or linux?)
- they may be largely inflexible (how are the posts formatted? how does the parser work?)
- they may not be updated in time (are they actively maintained?)

the votecounter was built with correctness in mind - it will
always
give you the exact same output if given the exact same input. That means things like multiple votes in a single post are resolved in the same way, every time. the votecounter guarantees:
- it will always resolve votes the same way
- it will only resolve votes that it's sure (or almost sure) are correct - otherwise, it's designed to fail and require human intervention to protect game integrity and ensure correctness
- it will always warn if it's not
really
sure of a vote

The only drawback, so far, is that
it will not count bolded votes - only votes in vote tags. If there is demand to change this, I will.


this votecounter is written in python. it's effectively infinitely extensible, by virtue of being FOSS (free + open source software) - it's MIT licensed, so go nuts - and easily maintainable by anyone with working knowledge of Python. it's also auditable by anyone with working knowledge of python, so you can rest assured it's not gonna pwn you and steal your credit card number and family pictures.

I opted for a CLI (command-line interface) utility instead of a graphical interface. This means the code is simpler to write and maintain, it's more lightweight, and it can run (basically) anywhere. if you're not a wiz or if you've never used a CLI in the past, fret not! Here are a few tips to get you started, depending on your platform. Remember you only need to run setup once!
Spoiler: windows
Spoiler: setup
if you're on windows, you should have powershell already installed - it ships with the OS. You'll need git and python - the easiest way to install these, to me, is with chocolatey. You can follow the instructions on that page, under "individual", to install it. Once you've installed chocolatey, start powershell as admin and run:

Code: Select all

choco install python git
python -m pip install ruamel.yaml jellyfish coloredlogs requests bs4 jinja2


now that we're done installing our dependencies, navigate to the folder you want to download the vote counter to. For example, if I want to download it into a folder called "mafiascum" under my documents folder:

Code: Select all

cd C:\Users\osuka\Documents
mkdir mafiascum
cd mafiascum

then, download the votecounter:

Code: Select all

git clone https://github.com/fbastos1/mafiascum-modtools.git


git should create a new folder, mafiascum-modtools. navigate to that:

Code: Select all

cd mafiascum-modtools


then simply write your game definition file and optionally, your template and you should be good to go! For example, I would run:

Code: Select all

python ./votecounter.py mygamedefinition.yaml --template osuka.jinja

(simply substitute "mygamedefinition.yaml" and "osuka.jinja" with your game definition file and template file names, respectively)

you're all done with the setup!


to run this again after setup:

open a new powershell window and just navigate to the folder you created and run the votecounter:

Code: Select all

cd C:\Users\osuka\Documents\mafiascum\mafiascum-modtools
python ./votecounter.py mygamedefinition.yaml --template osuka.jinja


you should also keep it up to date! to make sure you have the latest version, make sure your terminal is in the folder you downloaded the votecounter and run:

Code: Select all

git pull

Spoiler: macOS
Spoiler: setup
if you're on macOS, i cannot recommend homebrew highly enough. open up the Terminal - that's where you'll install brew - and once you've got homebrew installed, run the following:

Code: Select all

brew install git python3
python3 -m pip install ruamel.yaml jellyfish coloredlogs requests bs4 jinja2


then, navigate to the folder you want to download the votecounter to and download it. For example, let's say I want to download it to a folder called "mafiascum" under my Documents folder:

Code: Select all

cd ~/Documents && mkdir mafiascum && cd mafiascum
git clone https://github.com/fbastos1/mafiascum-modtools.git

git should create a new folder, called mafiascum-modtools. navigate to it:

Code: Select all

cd mafiascum-modtools


now that we're done installing dependencies and getting the votecounter, write your game definition file and optionally, your formatting template, and you should be good to go. For example, I'd run:

Code: Select all

python3 ./votecounter.py mygamedefinition.yaml --template osuka.jinja

simply replace mygamedefinition.yaml with the name of your game definition file and replace osuka.jinja with the name of your template file!


to run this again:

open a new terminal window, navigate to the folder where you downloaded the votecounter, and run it:

Code: Select all

cd ~/documents/mafiascum/mafiascum-modtools
python3 ./votecounter.py mygamedefinition.yaml --template osuka.jinja


you should also keep it up to date! to make sure you have the latest version, make sure your terminal is in the folder you downloaded the votecounter and run:

Code: Select all

git pull

Spoiler: linux
todo lmao if you're on linux i assume you probably know how to use the cli. install git and python3, then install the dependencies as shown in the github page. i'll prob write this at some point in the future lol sorry


also, most of the vote counters i've ever seen assume certain things about how post #0 is formatted or other things. I don't like that, so i decided to build a solution that worked for me in the way i wanted it to. the votecounter works with a game definition file - the specifications of which can be found in the github page, as well as an example of a game definition file. Writing the game definition is a one-off - when you do it, you shouldn't have to do it again for the same game, and it should take only a few minutes to set that up. After that, it's just a matter of running the votecounter and letting it do its thing.

But wait! there's more!

It also optionally formats posts for you! I'm a lazy shit and i don't wanna format posts by hand, so the votecounter uses Jinja to format posts in whatever way you want them to be formatted and just outputs the phpBB code for the post, (mostly) ready to go. There's also an example of this, as well as some more details, in the github page.


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #1 (isolation #1) » Sat May 06, 2023 2:22 pm

Post by osuka »

please please please let me know how this works for you! what do you want to see? what sucks? what doesn't suck?

if you have problems with the setup or if you find something wrong with it, please let me know! i want this to be useful to more people than just myself so don't be afraid to ask or complain!


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #5 (isolation #2) » Mon May 08, 2023 7:16 am

Post by osuka »

In post 3, RH9 wrote: Egoing.
I might use this for the next time I mod something.
let me know how it goes!


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #6 (isolation #3) » Mon May 08, 2023 7:20 am

Post by osuka »

In post 4, yessiree wrote:
In post 0, osuka wrote: available at https://github.com/fbastos1/mafiascum-m ... /tree/main pls dont dox me
HE'S FELIPE everybody his name is Felipe

jokes aside, you can process up to 200 posts at once like this, should be much fewer requests to the server
viewtopic.php?t=90886&view=print&ppp=200

how good is the username string matching algorithm you are using btw?
I gave up trying to write my own votecounter because I couldn't find a satisfactory solution without resorting to extensive configs, or venturing to NLP category (despair)

i think the CLI format is pretty user friendly already, but might still pose as a barrier to entry for a lot of non tech-savvy people, one step further u can take is a browser extension so people can install on Chrome/Firefox and it can make modifications to the DOM directly while in the mafiascum.net domain

I think jacksonvirgo was tryna do that, not sure how thats going now tho
i can patch it to use ppp - i didn't know that existed. good call!

the votecounter uses jellyfish's implementation of jaro-winkler similarity, but with a
very
high confidence threshold. it's designed to fail if it can't decide with almost near-certainty what a vote is - i wrote it that way to protect the integrity of the game and make sure that if there is a need for human intervention, that happens at the earliest possible moment rather than waiting until the moderator realizes something is wrong.

the fuzzy matching is Good Enough(tm) - it's not groundbreaking and, by design, it doesn't try all that hard to match a vote. it does fuzzy match aliases, though, so if there's a vote for an alias of a player and
that
has a typo, it should still work fine

i don't wanna do a browser extension because that's a whole lot of extra work that i don't think is gonna be all that helpful to begin with. userscript could work?


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #10 (isolation #4) » Thu Jul 06, 2023 6:15 pm

Post by osuka »

In post 9, Psyche wrote: i have a pretty solid username matcher that i basically finetuned through brute force. is even in python! will share when i have the time
you should be able to patch that in relatively quickly

do you think there would be interest in importing the username matcher implementation as a module? that way if someone wants their vote counter to be more/less strict, then the counter logic itself and the formatting stuff still work, with any arbitrary implementation of a name matcher


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #13 (isolation #5) » Sun Jul 09, 2023 8:50 pm

Post by osuka »

In post 12, Random Nurse wrote: Can anyone here confirm that this auto votecounter is working on this site currently?
working fine for me as of about 30 seconds ago

have you had issues?


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #19 (isolation #6) » Tue Jul 25, 2023 3:12 am

Post by osuka »

In post 18, Random Nurse wrote: For laypeople like me how exactly do I get this running? I have an HP laptop that uses Windows.
were the instructions in #0 hard to follow?


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #21 (isolation #7) » Tue Jul 25, 2023 1:14 pm

Post by osuka »

In post 20, Random Nurse wrote:
In post 19, osuka wrote:
In post 18, Random Nurse wrote: For laypeople like me how exactly do I get this running? I have an HP laptop that uses Windows.
were the instructions in #0 hard to follow?

I'm not familiar with using Github.
you shouldn't have to open github at all, unless you want to look at the code on your browser. Look for the spoilers in #0 - I'll quote them here but i'll also note for any future readers that this may be out of date, so you should check the OP for the most up-to-date instructions
In post 0, osuka wrote:
[...]


Remember you only need to run setup once!
Spoiler: windows
Spoiler: setup
if you're on windows, you should have powershell already installed - it ships with the OS. You'll need git and python - the easiest way to install these, to me, is with chocolatey. You can follow the instructions on that page, under "individual", to install it. Once you've installed chocolatey, start powershell as admin and run:

Code: Select all

choco install python git
python -m pip install ruamel.yaml jellyfish coloredlogs requests bs4 jinja2


now that we're done installing our dependencies, navigate to the folder you want to download the vote counter to. For example, if I want to download it into a folder called "mafiascum" under my documents folder:

Code: Select all

cd C:\Users\osuka\Documents
mkdir mafiascum
cd mafiascum

then, download the votecounter:

Code: Select all

git clone https://github.com/fbastos1/mafiascum-modtools.git


git should create a new folder, mafiascum-modtools. navigate to that:

Code: Select all

cd mafiascum-modtools


then simply write your game definition file and optionally, your template and you should be good to go! For example, I would run:

Code: Select all

python ./votecounter.py mygamedefinition.yaml --template osuka.jinja

(simply substitute "mygamedefinition.yaml" and "osuka.jinja" with your game definition file and template file names, respectively)

you're all done with the setup!


to run this again after setup:

open a new powershell window and just navigate to the folder you created and run the votecounter:

Code: Select all

cd C:\Users\osuka\Documents\mafiascum\mafiascum-modtools
python ./votecounter.py mygamedefinition.yaml --template osuka.jinja


you should also keep it up to date! to make sure you have the latest version, make sure your terminal is in the folder you downloaded the votecounter and run:

Code: Select all

git pull

[...]
if you have any questions about the instructions or any of the steps
please
let me know - i come from a technical background and i'm knee-deep in a terminal on the daily, so the real test of whether my instructions suck or not is someone who's
not
me


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #24 (isolation #8) » Wed Aug 30, 2023 6:40 am

Post by osuka »

In post 22, JacksonVirgo wrote: Has been a month since the last post so I'm sorry for the useless bump but I am egoposting here from the depths of hell. I have arisen
no worries - i do watch the thread to try and help anyone who wants to use it


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #25 (isolation #9) » Wed Aug 30, 2023 6:45 am

Post by osuka »

In post 23, Random Nurse wrote: OK, so I don't particularly know what I'm doing here.

I have a Windows laptop and searched and found "Windows PowerShell," and ran it as an Administrator.

It's showing me this screen:

Image

I have no idea how/where to run "Get-ExecutionPolicy."
the image isn't loading here - might have to do with google drive permissions. Can you try imgur?

powershell is a command line utility, so you'd type that command in the window and hit enter. Here's what that would look like:
Spoiler:
Image


Mine's set to Unrestricted - but if yours says Restricted, make sure you copy and run the command in the chocolatey install page there before you move on to step 4. step 3, confusingly, is just telling you again to run the long command right above it


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #42 (isolation #10) » Fri Sep 01, 2023 12:26 pm

Post by osuka »

i didn't write a browser extension originally because i honestly couldn't be bothered to write and maintain a userscript. i hate javascript and it's just about the last language i'd choose for any personal project, honestly.

for what it's worth, i wonder why this isn't a part of the actual forum in the form of a phpbb extension. would that suck a lot?


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #43 (isolation #11) » Fri Sep 01, 2023 12:28 pm

Post by osuka »

i wonder if a simple shell script for this would suffice to help with lowering the barrier to entry?


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #58 (isolation #12) » Mon Sep 04, 2023 10:45 am

Post by osuka »

we should never automate account creation or batch posting. matter of fact i chose not to automate posting because:
- it gives the moderator a chance to verify everything
- it avoids mistakes, including posting on the wrong thread
- it reduces risk by only making unauthenticated requests


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #59 (isolation #13) » Mon Sep 04, 2023 10:46 am

Post by osuka »

i think a page top isn't even that big of a deal, honestly - i usually just iso the mod if i'm looking for a vc. do you guys not do that?


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #62 (isolation #14) » Mon Sep 04, 2023 9:26 pm

Post by osuka »

i think auto posting is genuinely too dangerous to have out in the wild. we have to consider that post requests (including authentication) might put a lot more strain into the server than a typical unauthenticated get request


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
User avatar
osuka
osuka
he/him/his
Jack of All Trades
User avatar
User avatar
osuka
he/him/his
Jack of All Trades
Jack of All Trades
Posts: 5898
Joined: July 2, 2017
Pronoun: he/him/his
Location: with my scumpartners

Post Post #66 (isolation #15) » Tue Sep 05, 2023 9:30 am

Post by osuka »

let’s see what the admins have to say - if there is an actual phpbb api?l, i’d be much more comfortable shipping the pagetopper since we’d be able to talk about things like rate limiting and api key revocation in case shit goes sideways


"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi

Return to “Mafia Discussion”