So i made a discord bot & hosted on replit. I set up a pinger, bot is alive, it works, everything is fine.
But what is the problem then?
Well,
This means that the bot is online, is up for pings, AND has logged in, but is not responding to messages.
After i use kill 1, my bot runs fine. Maybe my bot is being rate limited??
So i made a .sh file. It has this code
while true; do
node .
done
and here's my .replit
entrypoint = "index.js"
run="bash restart.sh"
### stuff after this not important
Yeah, it works. Everytime my bot is being rate limited, i use process.exit() to restart, and my bot really did work for 3 days.
But then back to before. Bot online, logged in, not responding. Again I have to use kill 1 to restart
Is there anything im missing? or is this some problem with replit's or discord's servers? Can I do anything to fix it, or at least automate it?
Related
I face a somewhat weird problem. Unfortunately, I have to diagnose and repair it from distance without any real access. So I don't know if I can provide enough information to solve it.
Context:
I built an interface for my grandma (94) to chat with the family via telegram by connecting a Telegram bot to a microphone (for her to record voice messages) and a small printer (for the messages to be printed for her). [This is inspired by the Yayagram invented!]
The problem:
For the last one year, everything worked just fine. However, a few days ago, the bot stopped working. My grandma could not send any voice messages and didn't receive any of our messages. After calling her and checking all the connections, we restarted the device. Now, she can send voice messages, but the bot still doesn't process our text messages (nor commands!).
I have never encountered a bot being able to send messages without processing incoming messages. As I said, I have no way to analyze the problem in detail as my grandma lives 500km from me. If anybody has any ideas where the problem could be, I would be very happy.
Edit:
I knew it would work to post a question on StackOverflow! Out of nowhere, the bot seems to work again. I have no idea what caused it, or why it started again as I did nothing. I am still grateful for any insight for what might have caused it!
I've made a telegram bot, that sends a request to a certain API and returns the answer to the bot.
when I run the app locally, it takes like 2-3 seconds to execute a request and send the answer to the user, but when its webhook to pythonanywhere, it takes 5-10 minutes to execute a request.
is it really that slow? or something is wrong?
That really seems like something's wrong. Instrument your code with some timing information so you can see where it's spending it's time. Then you can start to try to work out why there's such a big difference.
I am newbie in programming, so I'm asking to be, let's say, more patient. Thanks.
Now what I want to ask.
So I have a discord bot that check minecraft server status. By checking server status it set for himself Playing status like "Playing x/y players" or "Server unavailable". I want to make notifications when it will send message if status "Server unavailable" changes to "Playing", so users of my discord server get notified when server up. More better will be if notifications will be sent only if server was unavailable for more than X minutes.
One more thing. I do Not ask for sample code, but for directions for what I'm should Google, so I can write code by myself.
Thanks for any help!
Oh btw, bot is written on Node.js.
I have a node script I'm working on that connects to an IRC channel for twitch.tv and responds to commands, as well as moderates chat lines that are being sent by other users connected.
Currently I open a terminal to the file location and run node app.js to start the IRC connection. But this runs on my mac and I use my PC to play games and watch the chat, so I have to have the Mac next to me to start and stop the IRC chat client app.
I want to move this to a web server where I can log in and start or stop the chat client app from the website, so I don't have to have the Mac next to me all the time.
What would be the best way to go about this?
If you want to see the script I'm working with you can find it here
https://github.com/Jordan4jc/super-fly-twitch-bot
You could create an HTTP server and listen on a port (if you don't mind overkill, express.js could make things easier for you). This server would contain configurations for the URL, authentication, etc. Within the callback that you provide to a URL path, you could close the IRC channels, database connections, and call process.exit(0) once you're confident that you've done everything necessary and you're sure it's what you want.
You can use socket.io as a way to send signals in real time to the application.
We've built simple node.js socket.io chat from an example chat document. Here is our problem that we've stucked with;
When A person clicks to B person for chat it says "it's ready start conversation"
When they send message nothing happens, hitting enter only clearing message neither A nor B person sees it.
But if they do f5 both it says "it's ready to start conversation" again and now they can chat without any problem.
With this first trigger every chat can be made without f5. For example after 1-5 hours if C person clicks to D person they can start conversation without problem.
But if a day passed without any conversation people that starts first conversation on that day has to make f5 to make some kind of trigger. Then anyone after them starts without any problem.
The server goes some kind of timeout or screensaver mode..! People on first conversation always have to make f5. Then it works for a day.. I am not sending any code or something we need guidance what to look for. Node.js? socket.io? What can cause this silly problem? Thx
But if a day passed without any conversation people that starts first conversation on that day has to make f5 to make some kind of trigger. Then anyone after them starts without any problem.
This sounds like you're trying to keep a websocket connection open for several days without any client doing any reconnect?
If this is the case, then maybe it is a clientside problem. Perhaps the browser closes the websocket-connection after a long time. Your web app doesnt recognize the lack of connection and still shows "it's ready to start conversation". But browser doesnt send any messages to the server anymore.
Check this thread: howto reestablish connection
It would help a lot, if you show us some code.
Best regards