Record discord bot uptime with uptimerobot.com [closed] - discord

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm making a statuspage(statuspage.io) for my discord bot, and I want to record the downtime automatically with uptimerobot.
But I have no idea how. Does a discord bot (written in python) use a specific port, which can be used to see if the bot is online?
Or do I need to do this somehow with the discord API to check if the bot is online?
I haven't found anything, except something with a discord bot hosted on glitch, but I don't host anything on that site, I host it myself.
Also how do I connect uptimerobot with statuspage?

For uptime robot to work, you need a publicly facing webpage that it can request every 5 minutes.
Two options:
Your discord bot needs to run in the cloud and run a http server at the same time
Have your web server accept another request like example.com/keepalive to tell the server that the bot is still running.
Uptime robot would then query example.com/alive and you have to return 200 OK if the bot is online and 404 if offline.
NOTE: If you already have something like the 2nd approach running, you may as well just save the uptime info on your public server. I also recommend passing some authentication in headers or as a query (password, for example) if you use this to avoid people abusing it.

Related

Delete the user from the database after a while in Laravel 5.7 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I had a question, for example, if a user registers on our site but does not verify his e-mail after a while, the user's information will be deleted from our database?
Example:
User::all()->where('email_verified_at',null)->delete()
You can use a timed script in your Laravel App.
First, create a new artisan command
php artisan make:command ClearUnverifiedUsers --command=my-command:clear-unverified-users
In your app/Console/Commands/ClearUnverifiedUsers.php
use App\User;
...
public function handle(){
User::where('is_verified','=',false)->delete();
$this->info('Clear unverified users!');
}
...
add this to your Kernel.php
protected function schedule(Schedule $schedule){
// do this command every hour
$schedule->command('my-command:clear-unverified-users')->hourly();
}
last, make sure you had set a timed task in your server:
run this in your server
export EDITOR=vi && crontab -e
add this to Cron Task Plan
* * * * * php /your-project-location/artisan schedule:run >> /dev/null 2>&1
clear your cache
php artisan cache:clear
No, the user data will not be deleted from the database.
However, the verification link will expire after a while and the user will need to login again to for a fresh verification link be sent.

Discord Bot [Help Needed] [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I need help with a discord bot and coding I never actually coded a discord bot so this is what I need help with. So I need help with making a discord bot chat like if I was to make rules it could make the rules chat pop up like
[USERNAME]
;Rules
Delete The Message I Said
[BOT]
Rules Here
Like this image
This is quite the lengthy response, but I recommend reading the entire thing.
StackExchange is a community where people post and discuss code. With all do respect, I can guarantee you that nobody here, including me, is going to write you code if we cannot see what you have tried or any existing code.
You will definitely have better luck on this site if you have a relevant product that people can look at to find errors and/or help you build upon it.
In the meantime, check out the Unofficial User Discord API Server here: https://discordapp.com/invite/discord-API
When I was in your shoes, this discord server was extremely helpful with answering any questions about the Discord API as 99.9% of the people there know exactly what your issue is and how to solve it. People are always online to take your questions as you build your code.
If you need help with starting your code, the basic steps go as follows:
Pip install the discord API
Create a bot user on https://discordapp.com/developers/docs/intro
Use the bot token to write your code
Because I don't know exactly what progress you have made on your bot thus far, I just strung together some wireframe code in python to get started.
import discord
import asyncio
from discord.ext import commands
description = "desc"
bot = commands.Bot(command_prefix='?', description=description)
#startup command
#bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
#category of main commands
class Main_Commands():
def __init__(self, bot):
self.bot = bot
#ping command test
#bot.command(pass_context=True)
async def ping(ctx):
await bot.say("pong")
#when the user types in ?ping, the bot will return "pong"
#This is an example of a simple command in this language
#RunBot
bot.run("TOKEN GOES HERE")
# (C) 2017
# All rights reserved
# Any part of this program may be used and/or modified at the users discretion
Anyways, I hope this response helped you.
Happy Coding!!
P.S. check out the API Reference http://discordpy.readthedocs.io/en/latest/index.html
What is in that image is an embed. Im my opinion, Discord.js is a very user friendly Discord API. You can find the docs here.
Rich embeds come with the Discord API, and they are really easy to use. Here is an example.
const embed = new Discord.RichEmbed()
message.channel.send({embed});
To actually put something in the message of your embed, you want to add attributes to the embed. They are as follows:
Attributes:
.title("title name")
.setAuthor("Author Name", "URL to picture you want to the left of name, optional")
.setColor(hex color code)
.setDescription("text")
.setFooter("text", "URL to image")
.setImage("URL to image")
.setThumbnail("URL in top right of embed")
.setTimestamp()
timestamp is at the at the bottom, nothing goes in the function
Attributes, continued:
.setURL("URL to make title clickable")
.addField("bold text",
"text")
this is what was used in the image you linked, there can be more than one field.
One more attribute:
.addBlankField(true)
To send the embed, in discord.js, simply do
message.channel.send({embed});
you defined embed earlier

Facebook Messenger - postback outages? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I have been successfully developing Facebook Messenger bots for the past couple months and lately have been experiencing an issue where 'postbacks' are sometimes not sent to my server, even though plain typed messages are sent immediately and of course web hooks validate fine.
Sometimes with enough teardown/subscribing of web hooks and pages the postbacks work again but I can't always get it to work again. I have multiple bots and multiple pages running not sure if that is related.
Also, yes I'm currently subscribed to receive postbacks.
Has anyone else experienced this? Thank you
It may have been resolved by now, but i was finally able to figure out when does postback work, and when it does not.
As per my observation, and many tests I came to conclusion, that facebook uses the same access token to "postback" which is used to create the persistant menu, generic template button, or a button template.
If the page Id, or the APP id (which is more probable, as people have a prod and test app for the same bot) differs, the postbacks are not sent back to webhook even though the webhook has the "messaging_postbacks" subscribed.
In my case it turned out the the page access token was generated with the production APP id, and i was testing in my test app, which had different app iD. Also, my persistent menu also worked when generated thru a test app access_token.
As a best practice, i hard code the access token (safer as well, as the generated access_tokens expires in some time) if the environment is not prod, and use the logic to generate the token when the app is live.
Update:
So it turns out after 44 hours of firefighting, the problem auto-corrected itself. Facebook team replied that all they have is a 502 error. and that too resolved automatically. I have contacted my domain provider and AWS and they said that that the issue is not at their end.
My conclusion, something must be happening in facebook's infrastructure as the same domain cannot have partial 502 errors (meaning for one use case it happens and other it doesn't when the webhook url is same). Hopefully, they figure it out even though they don't tell us.
So I don't have any reputation points for commenting so I am posting as an answer. I am facing a similar issue, the only difference is we are getting a quick response in postbacks but not messages.
We are consistently facing a problem of irregular incoming messages on our server for messenger bot. Our observation is that we receive a payload only after a few (random) seconds after the message has been typed (and sent) by the user. However, facebook instantaneously sends us the necessary payload if a buttontap is performed.
We have established that the apache server is not receiving any request (during that time). We have also established that our SSL certificate is not expired. Moreover, we have all the necessary ports open on our AWS instance (mainly 443 and 80).
Any clues anyone? we are facing this issue for last 21-22 hours.
I got the same problem yesterday, while developing the second facebook messenger bot (for the second Page). The postback wont come after some hours, that's what ridiculous (as I expected, the messages shouldn't come!!!).
The reason was the Page Access Token for the second Page was wrong! You have to pick the right Token from the right App. Because it's possible to generate the Page Access Token for the second Page from the first App.
While subscribing to webhook select messaging_postbacks checkbox.

Best implementation (folder structure) of SPA with Yii2 and AngularJS 2 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
As you know angular 2 is in beta right now.
Generally is it good to start a single page application (SPA) using angular 2 and yii2 as a RESTful API (for backend services)?
Assuming this:
how could be the structure?
What is the best implementation of this? (with sample)
Update:
Sorry, but I'm not good in English. I think the usage of implementation was wrong. I mean what is the best folder structure for using yii2 and angular 2 as a SPA like this repo.
Last Update:
As #SalemOuerdani told and mentioned I think that this link is my answer. maybe my question is a duplicate! Sorry for that!
The Yii2 quick start example for REST gave those endpoints as example:
GET /users: list all users page by page;
HEAD /users: show the overview information of user listing;
POST /users: create a new user;
GET /users/123: return the details of the user 123;
HEAD /users/123: show the overview information of user 123;
PATCH /users/123 and PUT /users/123: update the user 123;
DELETE /users/123: delete the user 123;
OPTIONS /users: show the supported verbs regarding endpoint /users;
OPTIONS /users/123: show the supported verbs regarding endpoint /users/123
Well that is REST. It doesn't matter which tool or framework to use. You can rebuild the same using Ruby, C or NodeJS and steal being the same app. Just have it in seperate folder or server and call it backend or server while it retreives data from DB or whatever else to answer the previous URI's.
The frontend in this case is the other app built with whatever language stored in a different folder or server that when it does a request to GET /users will expect a json response. when it does some edits on user 123 and send it back to server within PUT /users/123 it will expect the server to responde with a 200 response to know that it has been saved to database or a 422 error for example if validation fails.
My advice is to work with both tools as separate things. I don't recommand changing Yii's default rooting. The commun point between both should be the standards and concepts or architecture you did decide to implement or design for your HTTP requests.
More answers and a valid structure for Yii and angular may be found in the following:
What exactly is RESTful programming?
Yii2 + AngularJS in a single application - how?
How could be the structure?
There are alot of github repo's available for the best structure of angular2. you could refer to those for structure of your app,
this one is good repo i had ever found here:-
https://github.com/mgechev/angular2-seed
here is my repo you can refer to this too...
https://github.com/MrPardeep/Angular2-DatePicker
What is the best implementation of this? (with sample)
For implementation there are alot of tutorials and articals are there on the internet, but i personaly suggest to refer from the
official website of angular first.
https://angular.io/guide/quickstart
http://angularjs.blogspot.in/2015/12/angular-2-beta.html
http://www.angular2.com/

Squid reverse-proxy for site on Google AppEngine [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm setting up a squid 3.1 reverse proxy server (accelerator) for my website on Google AppEngine. The squid.conf looks like this,
http_port 80 accel defaultsite=my.public.domain.name ignore-cc
cache_peer mysite.appspot.com parent 80 0 no-query originserver login=PASS name=gaeAccel
acl gae dstdomain my.public.domain.name
http_access allow gae
http_access deny all
cache_peer_access gaeAccel allow gae
cache_peer_access gaeAccel deny all
Squid redirects me to the Google's search home page.
As soon as I changed mysite.appspot.com in cache_peer to anything else, such as www.yahoo.com, it worked.
Any idea?
It's on Ubuntu Server 12.04, Squid 3.1.
Thanks in advance,
Will
If you only want to bypass GFW, use Cloudflare.
Using your own proxy server makes it a single point of failure, effectively defeating one of main purposes of GAE - reliability.
App Engine already has their own transparent caching servers:
For static content you can set this explicitly via expiration attribute.
For dynamic content you can set Cache-Control http header, which Google transparent cache will then honor: http://davepeck.org/2011/10/25/a-word-on-app-engine-caching/
Note: you still pay for the bandwidth at $0.12/Gb. But OTOH, you proxy and it's traffic are free neither.

Resources