Skip to content
TORNLIFE More

Faction Activity Bot

Started by Multipass [1955315] on in API Development.

3 replies · 291 views · thread synced · 6 days ago · View on torn.com
About this thread

Posts archived: 4 / 4 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
4
Discussion span
→
People posting
3
Likes on archived posts
13
Authority score
52 / 100
Historical score
22 / 100
Story score
33 / 100
Engagement score
53 / 100
Multipass [1955315]
Hi all, so i made a thing and thought I'd share.

Long story short, I made a bot for our discord server that can list the stats of our members over time. This works by pulling each members data from the API once a day and comparing it to previous days to see how it changed in between.

As a very simple example, if I ask the API its tells me my total xanax taken - lets say its 100. If i ask again 2 days later it tells me my total is now 105. So this bot looks at those two stats and subtracts the older date from the most recent date and ends up with 5 xan taken over 2 days.

It can do this for a whole bunch of stats that the API serves up, including energy trained for each stat and total energy trained (the sum of all 4 stats).

I have the bot working for 3 facs now - it determines which data to present based on which server the message comes from. It can display data for these three facs since it joined their server - so 4 days so far and when you ask the bot you can choose how many days to compare.

Anyway thought someone might like this.

Pic of test command and list of keys for data the bot can track:

[image: i.imgur.com]

What it returns - this a list of all fac members and how many energy refills they used in the last 4 days. I blurred out the names.

[image: i.imgur.com]
LouBaker [1162207]
I am glad to hear you say

pulling each members data from the API once a day and comparing it to previous days

that's exactly how Personal stats should be used, not like some of the nitwits pulling personal stats every 30-seconds

I did a similar thing when API's first came out and we didn't have Discord then it was IRC (Internet Relay Chat)


members would type: !getstats or !ps with part or all of any personal stats name and it returned the required stats

[image: i.gyazo.com]



well done nice job
Multipass [1955315]
Nice! I remember IRC ; )

yeah I only need to pull once a day as the purpose was to be able to compare over time - didn’t need to be very granular. So each daily request is parsed and stored in a big csv file (my version of a database for this project). Then I can compare entries in they file between dates using a simple python script that is separate from the script that collects the data.

Calling the python scripts from a bot was actually pretty easy in the end. I never used node.js before so took me a few sessions to get my head round stuff but was much simpler than buildings UI.