Getting number of active voice connections - node.js

I usually work with discord.js but now I'm contributing to a package that supports discord.io too (it's dbots.js btw).
I need to post bot stats to discordbotlist's API and they support the number of active voice connections too: how can I get it in discord.io?
I've tried searching for properties and method in the docs but I can't find anything like discord.js' Client.voiceConnections.
Does anybody know how to find it?

The guy the owns the package figured it out:
Object.keys(client._vChannels).length

Related

Discord bot read all messages received when offline

I'm creating a discord bot that I would host with my PC so only some hours per day and I'm searching something that allows the bot to read all dms that he received while offline or similar.
I had two ideas to do this.
The first and simpler
call an iphotetic function that collect all the messages that the bot received when it was offline
The second
save the date when the bot goes offline
when it goes back online take all the 'open' private chats (so the ones that contains at least one message)
parse all the messages received from when it went offline to when it came back online
Right now I couldn't find anything on how to do this, any ideas?
Discord seems to have some nice looking api docs that are 100% covered by the discord.py library. I'd dig around there for a bit and see if you can achieve what you are looking for with it. Something as simple as a text file would work to store persistent data, maybe a timestamp or the last message id before the user logged off.
Both your ideas seem decent to me, I'd say just try building them and see if you run into any road blocks. By the time you do you will have a better understanding of the capabilities and limitations of the api and will be able to create a better plan.

How long does Twilio store chat history?

I've been browsing Twilio's docs and API reference but I was unable to find how long does the chat history is stored.
I don't have any own DB for storing messages as well as I don't have any other logic on my backend related to chat. I'm using Twilio to handle everything for me. I'm only using their client SDKs to interact.
Can anyone help me with that. Thanks in advance.
Twilio developer evangelist here.
My apologies for the delay from support getting back to you, but the good news is I have an answer for you.
At Twilio we store everything forever until you either:
Close your account
Delete the messages or channels yourself
Delete the entire service instance
So not fetching that from a database is the right choice in my opinion as it would potentially just add extra latency and logic into your code.
Hope this help yoiu.

WhatsApi Number Getting Blocked - NodeJs

I am using the node-whatsapi library
I am getting the number blocked. I am following the exact protocol as mentioned in the WIKI.
The flow that i follow is:
Create Adapter
Connect()
On Connect - Login
On Login
sendIsOnline()
requestPrivacySettings()
requestServerProperties()
requestContactsSync()
For Each Contact sendPresenceSubscription(), getStatus() and getProfilePicture()
And when i receive a message:
adapter.requestContactsSync('1234567890', 'delta', 'background');
getProfilePicture()
Save to DB
Now, what we do and why do we use WhatsApi
We enable our existing Customers to talk to their internal teams on WhatsApp. So, a customer initates a chat and a help desk team responds to them on an application.
Got the number blocked now. Unable to understand where am i going wrong.
Also, the total number of messages exchanged between the customer and the helpdesk team is around 1k a day.
What you're "doing wrong" is using a third party API which is against WhatsApp's terms of service and, if detected, will get your relevant accounts blocked. It's not a fault with WhatsAPI itself or how you are using it.
WhatsApp openly publishes the only approved/compliant way to programmatically interact with their network.
http://www.whatsapp.com/faq/en/iphone/23559013
http://www.whatsapp.com/faq/en/android/28000012
Outside of that, you are going to get blocked whenever you are detected as using an unapproved means of interacting with their network.
In your particular example you're using a Node.js port of the original WhatsAPI. As of May 2015 this is the kind of pressure they are dealing with from WhatsApp (despite many years of trying to negotiate an amicable compromise with them around things like message limits and identity verification):
It sucks but that's just how it is. You can look at some alternatives which are still actively updated and may continue working for a while, but given that WhatsApp is now owned by Facebook and considering the kind of legal resources at their disposal, you should be able to see why one might be reluctant to continue updating a rogue API.
Well, got a satisfactory answer from WhatsApi collaborator matteocontrini.
Here is the answer that i got, if somebody is intrested.
It says:
the reason of getting blocked doesn't have to be because you wrote
wrong code. It could be a filter on the kind of messages you send or a
report from someone about your number.

Can't figure out how to access Dice.com's REST API

So I want to use Dice.com's API to grab data for an infographic type application.
http://www.dice.com/common/content/documentation/api.html
My problem is they require a Developer ID and password. I'm not sure where I can get this since it's required for the OAuth token.
I plan on using Node.js to make requests to their RESTful service. Any information would be greatly appreciated.
I emailed dicemedia#dice.com (email grabbed from http://www.programmableweb.com/api/dice-jobs) and got a reply:
Thanks for your interest in the Dice API! It's currently not available
for public use. We've been field testing it at some events and hope
to open it up by the end of Q2 2015.
We'll definitely make an announcement when it opens up.
Please let me know if you have any other questions.
Thanks!
I found it pretty easy to get started hacking around with this using Postman (actually for searches you could just start in a browser, with a JSON plugin installed or the like).
http://www.dice.com/common/content/util/apidoc/jobsearch.html

User authorization in google talk with nodejs and node-xmpp

I'm writing a bot in node.js using node-xmpp. So far it's pretty straight forward except I'm having an issue with figuring out how google Talk handles it's user authorization (when dealing with requesting to chat with someone NOT on your roster).
I'm catching all stanzas coming through and logging them to the console but there is no data coming from the user that is requesting authorization.
Any explanations of what I should be looking for or if this event even happens over the jabber protocol.
[appended] I know that technically when a subscription request is made a presence stanza is sent with the subscription request. I can't see these coming over the wire using node-xmpp for some reason. Also, I need to find out a way to determine what presence requests are "pending" when my bot logs in. I thought (innacurrately) that they would be listed in the roster with some sort of flag, but that's not correct.
Any help with finding out where to go from here would be useful.
Ok, I finally figured out how to get the subscription requests after they have been made. There isn't much info on it out there so I'll put together a blog post, but I feel that answering it here might be good as well.
I found that if I did a google roster query based on the below information:
http://code.google.com/apis/talk/jep_extensions/roster_attributes.html
example stanza:
<iq from="username#gmail.com/D2D4E5A8" type="get" id="google-roster-1"><query xmlns="jabber:iq:roster" xmlns:gr="google:roster" gr:ext="2"/></iq>
The server would respond first with your pending server subscription "presence" stanzas
ex:
<presence type="subscribe" from="pendinguser#gmail.com" to="namehere#gmail.com/D2D4E5A8" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client"/>
and then the rest of your roster's "presence" stanzas. It's important to note that your subscription "presence" stanzas don't get sent to you from the server unless you do a roster query. I'm not sure why this is and why it's not documented somewhere is beyond me. Anyways, at least I can get the list of people trying to get access to my bot now.
Note: This is not my area of knowledge just an interest of mine. I have not got practical experience just a bit of research. This would have been a comment however doing some more searching on the topic, I have come up with some more things that might help.
Here's a google chat chat room homepage http://partychapp.appspot.com/ you can get the source http://code.google.com/p/partychapp/
Those links came from http://xmpp.org/2010/02/xmpp-roundup-13-services/ which has quite a few other resources that might be helpful.
http://code.google.com/p/node-xmpp-bosh/ has some code about that, I've not done it but the topic is interesting.
I hope if you do find the answer your after you write up a blog post and or a project and share it. It would be of interest to me.

Resources