Modbot to Help You Run Games: Now With A Votecounter Demo!

This forum is for discussion related to the game.
User avatar
Flubbernugget
Flubbernugget
Survivor
User avatar
User avatar
Flubbernugget
Survivor
Survivor
Posts: 11751
Joined: June 26, 2014

Post Post #50 (ISO) » Sun May 06, 2018 7:48 am

Post by Flubbernugget »

Sounds like you want a electron app
User avatar
yessiree
yessiree
he
Mafia Scum
User avatar
User avatar
yessiree
he
Mafia Scum
Mafia Scum
Posts: 4386
Joined: June 6, 2013
Pronoun: he

Post Post #51 (ISO) » Sun May 06, 2018 7:52 am

Post by yessiree »

In post 49, Psyche wrote:after a bit of research, i think the solution here is to give clients an application that starts a private, local server (like a pyinstaller-packaged flask app)
that delivers our html/css/js/etc-based user interface in their browser at http://localhost:.../
and talks w/ the interface to execute whatever python functions the clients need for their goals
have you considered Node.js? there is a built in http-server module that launches a local server
then you can use w/e js framework to hit your python endpoints
User avatar
Flubbernugget
Flubbernugget
Survivor
User avatar
User avatar
Flubbernugget
Survivor
Survivor
Posts: 11751
Joined: June 26, 2014

Post Post #52 (ISO) » Sun May 06, 2018 8:13 am

Post by Flubbernugget »

Node.js would probabaly have to replace the entirety of the Modbot code with js or suffer unnecessary complexity. Flask would probabaly handle this better since it's for python.

On second thought, electron may have the same issue as node.js, but I honestly don't know enough about it to say for sure.

Prodbot will probabaly have to wait till next week. I had an issue with my license plates being stolen this weekend.
Last edited by Flubbernugget on Sun May 06, 2018 8:22 am, edited 2 times in total.
User avatar
Flubbernugget
Flubbernugget
Survivor
User avatar
User avatar
Flubbernugget
Survivor
Survivor
Posts: 11751
Joined: June 26, 2014

Post Post #53 (ISO) » Sun May 06, 2018 8:17 am

Post by Flubbernugget »

If you're interested in a js/css interface, you may also be able to accomplish this with an index.html file that runs js with Ajax, but that again removes python entirely.
User avatar
yessiree
yessiree
he
Mafia Scum
User avatar
User avatar
yessiree
he
Mafia Scum
Mafia Scum
Posts: 4386
Joined: June 6, 2013
Pronoun: he

Post Post #54 (ISO) » Sun May 06, 2018 8:19 am

Post by yessiree »

node.js would only be hosting the web app that has the UI, not the main app
the python code base stays as is, the only change that's needed is to expose the current methods as endpoints so the clients can access them with XHR requests; there are a couple ways of doing that (the endpoints package comes to mind)
User avatar
Flubbernugget
Flubbernugget
Survivor
User avatar
User avatar
Flubbernugget
Survivor
Survivor
Posts: 11751
Joined: June 26, 2014

Post Post #55 (ISO) » Sun May 06, 2018 8:31 am

Post by Flubbernugget »

If the python has to expose xhr requests (which is ultimately just http), it would be just as capable of hosting a gui front end?

Psyche, what is your motivation for wanting the gui to be web oriented? I get that you don't want to reinvent the wheel, but there's a lot of batteries included python options in this regard (kivy comes to mind).
User avatar
yessiree
yessiree
he
Mafia Scum
User avatar
User avatar
yessiree
he
Mafia Scum
Mafia Scum
Posts: 4386
Joined: June 6, 2013
Pronoun: he

Post Post #56 (ISO) » Sun May 06, 2018 8:39 am

Post by yessiree »

vanilla python is pretty shit when it comes to implementing a UI. you also dont want to be dealing with any os related quirks that's guaranteed to come up. web based UI will probably give you the most bang for your buck, time investment wise
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10574
Joined: April 28, 2011
Pronoun: he/they

Post Post #57 (ISO) » Sun May 06, 2018 9:00 am

Post by Psyche »

biggest motivation is to make it easy to produce a user interface that looks good and works well across all platforms and is easy to change and improve going forward without thinking about the underlying functionality
in my experience, it’s just harder to make a whole new interface than to use what modern web browsers already provide us

maybe i’m wrong though
remain open to other ideas
and ofc even if i do stick to this approach, if someone wants to do it differently, our API will help them do that too
User avatar
Flubbernugget
Flubbernugget
Survivor
User avatar
User avatar
Flubbernugget
Survivor
Survivor
Posts: 11751
Joined: June 26, 2014

Post Post #58 (ISO) » Sun May 06, 2018 9:10 am

Post by Flubbernugget »

My line of thinking is that getting separate programming languages to play nice with each other is consistently a pain in the ass.

Yesirree has a point though that platform compatability is a bigger pain in the ass
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10574
Joined: April 28, 2011
Pronoun: he/they

Post Post #59 (ISO) » Sun May 06, 2018 9:13 am

Post by Psyche »

I agree that it’s a pain in the ass, but there are many kinds of pains in the ass
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10574
Joined: April 28, 2011
Pronoun: he/they

Post Post #60 (ISO) » Mon May 07, 2018 4:41 am

Post by Psyche »

ok ive tried a few things and thought some more and i think i will stick to flask rather than electron or stuff like it
the reason i was going to try to use electron or eel or whatever is because i thought it would result in a smaller app that would be easier to distribute in return for giving up the flexibility i like about flask (scale it into an external-facing server in you want!)

however, it seems that a packaged electron/python helloworld app takes about as much space as a packaged flask app, so in my mind i'm thinking "why give up functionality?"

if we make this in flask, and make it right, then users will have their client-side app they can use for their own purposes,
and also have the option of deploying it online such that their modbot instance can be accessible from anywhere as long as your main computer stays online

the biggest application of this possibility is that it would open the door to helping people mod games from their phones or other web-connected devices that aren't their "main" computer: as long as you'll be it's only user, it's easy and free to make a flask app web-accessible - an example: http://flask.pocoo.org/snippets/89/

beyond that, if someone
does
decide to maintain a persistent server for mods across the site to use modbot on, then an flask app will easily scale into that role just through configurational changes, while an electron app might not (or at least i don't know to do that)
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10574
Joined: April 28, 2011
Pronoun: he/they

Post Post #61 (ISO) » Tue May 08, 2018 7:16 am

Post by Psyche »

i want to quickly belt something out to test my ideas about a clientside app
i think to start i'll make a pagetopping bot
an app that stalks the input thread for opportunities to pagetop it

it's really simpke to make botwise (simplest approach would maybe be to just have donbot periodically check the number of posts in the thread, and if it's numberPosts % 25 == 0, post) so i can focus on the problem of making a client-side tool. At the same time, though, a bot to automatically reserve pagetops is a legitimately useful modding tool. Later, it can seamlessly scale into the votecount pagetopping bot that is this project's current medium term goal.

I'm planning to set it up with an index page that lists currently implemented modding tools, so that appending a new tool to the app is as simple as setting up another page.

This will all be really barebones at first, and improvements, at least by me, will focus on ease-of-use over beauty, etc.
User avatar
yessiree
yessiree
he
Mafia Scum
User avatar
User avatar
yessiree
he
Mafia Scum
Mafia Scum
Posts: 4386
Joined: June 6, 2013
Pronoun: he

Post Post #62 (ISO) » Tue May 08, 2018 10:53 am

Post by yessiree »

I have some ideas about a way to get all the most recent votes from living players
1. get a list of living players (most likely from config or a mod post)
2. get the ISO of all living players (through the activity overview screen), run these requests asynchronously, sort by timestamps in DESC order
3. parse the content and get the most recent vote/unvote, return the post #
4. wait for all the ISO requests to finish
5. compile the results
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10574
Joined: April 28, 2011
Pronoun: he/they

Post Post #63 (ISO) » Wed May 09, 2018 9:53 am

Post by Psyche »

pagetopper interface is done and doesn't look bad at all (though it does look plain!)
i've even tested temporarily exposing the app to the internet using the snippet described here: http://flask.pocoo.org/snippets/89/
enabling me to configure, start, and stop the pagetopper from the web browser on my phone

i still need to try packaging this app and ensuring the resulting exe is not too big and works on both mac and windows oses but - this all seems to be working out!

Here’s what it looks like on my phone: https://imgur.com/a/FlMk2XZ

I suppose I really need to leverage default values if I want this to truly be easy to use on mobile. Maybe let the user specify that stuff when they first start the server.
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10574
Joined: April 28, 2011
Pronoun: he/they

Post Post #64 (ISO) » Wed May 09, 2018 10:27 am

Post by Psyche »

me and radiantcowbells found a bug in getNumberOfPosts() that makes it fail when there are unread posts in the thread. disgusting.
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10574
Joined: April 28, 2011
Pronoun: he/they

Post Post #65 (ISO) » Wed May 09, 2018 12:13 pm

Post by Psyche »

So, yeah. I'm pretty satisfied gonna design the entire modbot around that simple interface. Will push all the parts to github when I feel like it.

Now that I have the pagetopper and the interface done, all I need to do is make the pagetopper pagetop with votecounts instead of genericly specified posts.
...and several other things
User avatar
yessiree
yessiree
he
Mafia Scum
User avatar
User avatar
yessiree
he
Mafia Scum
Mafia Scum
Posts: 4386
Joined: June 6, 2013
Pronoun: he

Post Post #66 (ISO) » Thu May 10, 2018 6:55 am

Post by yessiree »

In post 62, yessiree wrote:I have some ideas about a way to get all the most recent votes from living players
1. get a list of living players (most likely from config or a mod post)
2. get the ISO of all living players (through the activity overview screen), run these requests asynchronously, sort by timestamps in DESC order
3. parse the content and get the most recent vote/unvote, return the post #
4. wait for all the ISO requests to finish
5. compile the results
I finished the prototype for this. PR on github
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10574
Joined: April 28, 2011
Pronoun: he/they

Post Post #67 (ISO) » Thu May 10, 2018 7:17 am

Post by Psyche »

cool
the async thing is really interesting; i hadn't learned how to do that yet

also really like your use of the activity overview screen, as calling "getUserID" for each person would've been a bit more expensive;
i may split that into a separate donbot function if you haven't already, as it'll definitely be useful for a lot of different purposes
User avatar
yessiree
yessiree
he
Mafia Scum
User avatar
User avatar
yessiree
he
Mafia Scum
Mafia Scum
Posts: 4386
Joined: June 6, 2013
Pronoun: he

Post Post #68 (ISO) » Thu May 10, 2018 7:26 am

Post by yessiree »

we get a little boost in performance if we run code in parallel (ie. if we're getting the user id for 10 users, we can send out 10 separate requests simultaneously then wait for all to finish, VS sending one, wait for response, send next one, wait for response etc...)

for python people either go with asyncio or gevent
User avatar
Flubbernugget
Flubbernugget
Survivor
User avatar
User avatar
Flubbernugget
Survivor
Survivor
Posts: 11751
Joined: June 26, 2014

Post Post #69 (ISO) » Thu May 10, 2018 10:52 am

Post by Flubbernugget »

Looked through the PR's. Cool stuff!

What's the difference between gevent and asyncio? I know what a coroutine is, but don't have much experience with either library.

Also, any naming conventions in mind? I'm used to class names being nouns.

Prodpot PR up sometime before tonight!! Just got the code done. Tested it (only for one post with a prod deadline of zero days). Need to figure out the jupyter doc thing, and actually write docs next.
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10574
Joined: April 28, 2011
Pronoun: he/they

Post Post #70 (ISO) » Thu May 10, 2018 11:51 am

Post by Psyche »

i can do docs if need be but jupyter notebooks are pretty easy to make
User avatar
Flubbernugget
Flubbernugget
Survivor
User avatar
User avatar
Flubbernugget
Survivor
Survivor
Posts: 11751
Joined: June 26, 2014

Post Post #71 (ISO) » Thu May 10, 2018 12:43 pm

Post by Flubbernugget »

I'm going to have to look into it tomorrow. Will send a PR with no docs, as the code is short and should be easy to read and understand.
User avatar
Flubbernugget
Flubbernugget
Survivor
User avatar
User avatar
Flubbernugget
Survivor
Survivor
Posts: 11751
Joined: June 26, 2014

Post Post #72 (ISO) » Thu May 10, 2018 12:55 pm

Post by Flubbernugget »

Do I need to be whitelisted/authorized to submit pull requests?
User avatar
Psyche
Psyche
he/they
Survivor
User avatar
User avatar
Psyche
he/they
Survivor
Survivor
Posts: 10574
Joined: April 28, 2011
Pronoun: he/they

Post Post #73 (ISO) » Thu May 10, 2018 12:56 pm

Post by Psyche »

Dont think so
User avatar
Flubbernugget
Flubbernugget
Survivor
User avatar
User avatar
Flubbernugget
Survivor
Survivor
Posts: 11751
Joined: June 26, 2014

Post Post #74 (ISO) » Thu May 10, 2018 1:15 pm

Post by Flubbernugget »

Seems as though I had to fork from the github gui. I tried using a vanilla git clone for a "fork"
Post Reply

Return to “Mafia Discussion”