Discord Bot {Help} - node.js

I am sorry but there is no code attached to this, as I simply don't know what direction to go in. I have a bot made for a clan in Anigame. Quite simply there are weekly donations,(in this case it's 30k). For someone to donate, they can do .cl donate [number].
Ex: .cl donate 30000 | This donates 30k to your clan which is the weekly donation required and means you have donated for the week.
Tracking donations is a pain in the ass so I wanted to make a bot to do it for me.
What I wanted to do is make it so that this person that just donated 30k can do .info and it says something like this:
Weekly: Done!
Debt: N/A
The debt being for people that have missed a week's donation.
EX: Someone hasn't donated for 2 weeks, has 60k debt. This is the third week, and if they decide to donate 90k that week, the bot makes it so weekly donation is paid and debt is paid.
I also don't know how to make that become possible, and I hope you [reader] understand where I'm trying to go with this.
I have the base cron job code to make sure it resets weekly, I just don't know how to do the code)
Tldr; How to make it so that .cl donate (number) updates a Weekly Number under the command [.info]. I wouldn't normally be so specific so I can learn how but I don't know the commands associated with doing this kind of thing. Thanks~

You should start with researching databases (for example SQLite), and then coding your bot to input values to that database on each command, then calculate the .info command based on the values that specific user has in the database, then your cron job could reset the database weekly (or the bot could do that too, you do you). Here's a good tutorial: SQLite tutorial

Related

Automating electonic part orders

Every few months my team creates a list of parts we couldn't have predicted we'd need. For a while we've been going to digikey and mouser, typing about 1000 searches in, and seeing what supplier has the right quantity.
But part shortages have made the "quantity available now" fluctuate considerably hour to hour, and sometimes even minute to minute. Is there a way to setup notifications for when products have a certain amount available?
I've tried webscraping digikey with nodejs, and making a little dashboard of link's that turn green when they're ready to buy. That worked for a while until Digikey blocked my IP address
I've considered using their API's, but they don't appear to offer buy if <logic> event setters, and only offer 1000 requests a day
mouser api
digikey api
What would be the best tool for the job?

API key? Web scraping? arrest/jail records and court records? Im so lost

So, I'm currently doing a Web Dev bootcamp, I'm about halfway done and I'm trying to come up with a personal project to challenge myself and also have something useful that'll stand out. Anyways,
I have this odd hobby of monitoring everyone who's been arrested per week in Hillsborough County FL. Sometimes if I see an old friend who has been arrested, I immediately go to the clerk of court website for Hillsborough county and look at their court case and even get their CRA(Criminal Report Affidavit) aka Police Report redacted so I can see what they actually did. I'm really big into all of this, call it weird but I got sick of having to look up the arrest on florida.arrests.org or from
webapps.hcso.tampa.fl.us/ArrestInquiry and then having to go immediately to hover.hillsclerk.com to search court records and all court info regarding said person. I thought it'd be cool to construct a website where on the index page it's just 2 textboxes and 1 submit button. 1 text box being for First Name and the second being for Last Name. Once submitted, the First and Last Name are compared to a database and all arrests for Joe Macgyver come up and Joe Macgyver's court cases(open and closed) which include court dates, evidence submitted by the state, basically everything that happened in court on whatever day. So all arrests for Joe Macgyver in Hillsborough county come up and on the same page all court cases. I figured it'd be cool and it'd save me some time but I don't even know where to begin.
It looks like florida.arrests.org is gonna be more practical than webapps.hcso.tampa.fl.us/ArrestInquiry because they just recently made some changes and the sheriff's office is only allowing arrests within a 3 month time period to remain public record that can be accessed for free online. They also have a captcha that needs to be entered for every search done However, Florida.arrests logs every arrest made and doesn't delete anything and has records going back to the late 90s. I can't seem to find any way to get an API key for florida.arrests.org so I know its possible to do what i wanna do, I just dont know where to start and how to go about it. A friend suggested web scraping, I did some research and got a little confused. Can anyone possibly help point me in the right direction? I figured if I kept the searches down to only hillsborough county, it should make my idea a little easier.
Thank you,
SparklingCoffee

node.js InApp and schedule

I am doing a mobile game server using node.js. I used the Express and postgresql
I have two questions.
This game has a Inapp is 30 daily gems that user can get the gems in 30 days period. But I don't know how to implement the method let the server know the user bought this item and send the reward to this user every day.
This game has a special offer item in InApp. For example, a Christmas pack in 25/12 - 27/12. But I don't know how to set this 3 days can show this pack.
I am beginner in node.js. So I hope that you don't think my question is stupid. Thanks
Speaking at a high level, you have quite a few options.
For your gems requirement, you would probably have a field or table that represents this gem purchase, e.g a start date. If a user bought this package say on 1/1/2019 then your node server can have a process that runs once a day that queries the purchase table and give gems to any user where the current date is less than 30 days ahead of the purchased date.
Your table may look like:
user_id
date_purchased
gems_per_day
To implement this as a function that will run once a day, you may want to create a singular script for it and run it on a cron job once per day or create a Timer type class within Node that will run your function every 24 hours.
For your special offers, as part of your Store code, let's say you have a function that updates what items are currently available in the store, you run this code once per day (as one of the 2 methods mentioned above) and probably storing these items in your database. Similarly, you can check each day if the current date is within this "special offer period" and if it is, you can set that product within your database to be active.
Your table may look like:
product_id
enabled
or
product_id
start_dayMonth
end_dayMonth
Hope this gives you a few ideas of how you can lay this out. Happy to answer any questions

Realtime: Node.js, MongoDB and Redis?

Okay, first of all I want to tell you that I am new to all this techniques mentioned in the title.
I want to make an new app. Think of it as a real time trading engine (like for stocks for example).
So, there are two things that really matter:
Speed / Performance: Everyone has to see trades in realtime
Security: Same trades can be made simultaneously but only one can be successful
I thought about an approach like this:
If a user wants to buy 10 peaces of stock X for $100 each he places an order which I store with Redis (speed) and push it to all clients with socket.io. Well, as soon as another user wants to sell 15 peaces for $100 the script should check if there is an open buy order. If so, it saves it as a successfull transaction in MongoDB (persistance) and closes the buy order of 10 peaces.
In this example 5 peaces are left. The script would display that with a calculation like this: 15 (sell at $100) minus 10 (buy at $100) equals 5 left. Every time someone want's to trade something this calculation would be made because I don't know how many stocks are left for trading else.
Edit: Or I could subtract 10 peaces of the 15 peaces in Redis so that I don't need to calculate every time. But if something would go wrong, I wouldn't know what the original data was. That's a problem.
Now the questions are:
Would you make it like this? Better ideas maybe?
What would happen if two users make the exact same order in the same time? Could it happen, that it gets stored two times in MongoDB as different successfull transactions? Of course you could run an audit over Redis and MongoDB and compare it. But that would be a horrible solution.
Hope you understand what I'm trying to ask. Thanks in advance!
First of all if you do not know anything from the stack you are using, it is not a good idea to tell I need high performance (high availability, good security and so on). Being absolutely new to all the tools you are using you should be happy if it will just work.
As for your question: first of all take a look how other people have done similar things. Here is an open source bitcoin trading engine which uses node.js which makes it an excellent example to study (it is complex, so take a deep breath). If you want to use mongo you need to know that it does not support transactions, so you need to take a look how to implement them by yourself there. These two examples are really good in explaining it.

Developing Online multiplayer management game

I wish to create a college project on a simple online multiplayer management game which will involve players setting orders for the day/week and then obtaining profits. Being a relative beginner I am unable to figure out the architecture required for this task.
As far as I am concerned I would be needing the following things:
A text interface to display the status of ongoing events and to set orders in a web browser.
A certain application that would calculate the results every minute and update the database.
A database
Sorry for being so newbish, but any advice or links or books on how to proceed will do.
Please comment if any more information is required.
Any programming language would be fine. Pick a lang / arch you or someone in your group are familiar with. I'm mostly a PHP/ZF, Linux, Postgres guy. So I would...
Write a little ZendFramework app to collect your user's data and save to postgres database. I'd host it on a little Linux server. I like slicehost.com $20/mon, but there are cheaper. Or make friends with someone with a server.
Then for the update of the orders, use a cron job to run every minute. If the update process is complex, use another PHP script, else just straight SQL.
Why do you need to run updates every minute? Are people going to be updating it that often, if they are making orders for a day or week?
I would start with deciding on the equations that will be used in your model.
Then, that will help decide what you need in the database, to give the parameters to the model.
Then, once you have the database, you need to get information from the user, so decide what you need from the user.
For example you should have some random event that will make certain items go up or down in demand, or have resources become more common.
So, you may want to have information in the database that lists what each product is composed of.
If the model will have external information, or, if it is based on what others make, so, for example, last week shoes were not produced, so those that made shoes made a profit. This week everyone is making shoes, so there is too many, so the price went down.
This is why I think starting with your model, and testing your assumptions is the first step.
Any language, system, database will work well, just do what you feel comfy with. When you design the UI, do you want it to look fine on iphones and the Blackberry Razor? Then that will have a big impact on how you design the UI.

Resources