Notification at change of status - node.js

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.

Related

Telegram bot doesn't process messages anymore

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!

Discord - Chat to a bot on another server

Basically there is a server with a BOT, i want to make my BOT from my server send a PM to the other BOT, the other BOT is not on my server, is this possible?
This is not possible for two main reasons.
It's explicitly blocked by Discord. You'd get the following error:
The server responded with error 50007: Cannot send messages to this user
Bots can only send a PM to a user if they share a server with the user. So while the other bot does not need to be in your server, your bot will need to be in at least one server with the other bot.
Of course, point 1 makes this a moot point anyway

How to build friend list where user status is shown online/offline?

I've 2 ideas.
Idea #1:
Using Redis put people currently online into set. Then from client side user would periodically send a request to send him status for all of his friends. Server would make sql request to get all friends and find them in the redis set and if so then they are online.
Idea #2:
Using Redis PubSub, when you as a user are online you subscribe to all n friend channels. And whenever a user goes online he publishes on a channel that he or she is online. And whoever maybe listening will get notified.
Now I can't tell which one is more scalable and efficient.
I think idea #1 should be the solution. idea #2 CANNOT work.
Redis doesn't keep published messages. So if a client is NOT connecting to Redis, the message will be lost. When he reconnects to Redis, he won't receive any messages published before.
In your case of idea #2, when a user logs in, he has no idea whether his friends are already online. Because his online friends have published online messages before he logs in, and he won't get these messages.

Microsoft Bot Framework (MBF) - can't get video from Kik channel

I can't get my bot approved on Kik because of the following reason:
Your bot failed to respond to messages of the following types: start-chatting, video
I'll probably fix the start-chatting, but the video part is weird.
In other channels (e.g. Facebook Messenger) my bot intercept the video and can responds to it, but on Kik, it seems like I get no message at all when the user sends a video message.
Anyone familiar with that issue? Any help would be appreciated.
I'm using the Node.Js SDK.
I solved it. My bot service is running on Azure, and after 20 minutes of inactivity, the server is becoming idle and the response is delayed in about 15 seconds.

Some kind of timeout proglem with node.js / socket.io chat

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

Resources