Discord bot read all messages received when offline - python-3.x

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.

Related

How to make twitter bot track tweets from our followers?

I was making a twitter bot with Twit, I found making tutorials using T.stream('user')
to get stream data about our account, now its deprecated. So in 2021, how can i achieve these?
requirements:
Know when someone follows my bot, and make a thanks post.
Know when someone in my followers list or following list makes a tweet.
Also I have a doubt, when we use stream, old data is also coming, so how exactly stream works? if i only want latest tweets, I have to sent get by setting interval?
For the new followers, you will need to build something using the Account Activity API, which uses webhooks to send you event messages. You will need to filter for the follow events.
For new Tweets from people you are following, you will need to poll the home timeline endpoint. There’s no realtime method for this.

Slack #here mention in channel via Incoming webhook

So I have an alert channel that collects messages from slack via incoming webhook. It's one of many tools we use to monitor these couple of apps that normally run without issue, but if there is a problem we want to know right away so we can do something about it. I'm getting emails, etc. but I also want the channel wide slack messages.
What I'm trying to do seems simple enough, but it's not working. I want to trigger an #channel or #here message to alert all the users in the channel at the time, so if the error happens in an environment that matters everyone gets a notification. I'm following examples in the documentation using the <#ABC123> channel id but it's not translating into an #here directive, it's just plain text.
Either what I'm doing can't be done, or more likely I'm missing something somewhere or approaching this incorrectly. I'm guessing it's the latter, but at this point confirmation that I can't do what I'm trying to do is fine, I'll come up with something else.
Found it
Apparently the convention for the channel alerts are <!channel>, not <#C123> as is with users or channel ids, or <#channel> with channel mentions (though that does work, just not as a channel wide alert). Hope this helps someone eventually.

Python-telegram-bot Get old messages in chat within two timestamps

How can I get old telegram messages?
*I'm saving interesting stuff found online via sharing these links to a Telegram bot.
I would like to make a "read it later"-like app, organizing these links into weeks.*
When I call the "bot.getUpdates" method, of course, I get -as expected- new messages.
What if I needed to get last week messages?
How can I get every message between two timestamps in the past using the python-telegram-bot API?
Thanks in advance.

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.

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