i'm experimenting with Golang Telegram bot APIs and I have a problem with the ID of the message's file that i send to the bot.
I forwarded a message of type VOICE to the bot and in the code I read the unique ID of this file to understand if the bot received that voice message yet (... maybe forwarded by another user).
The problem is that when I read the ID with this code msg.Voice.FileID I get always a different string. But not completely different, the first and last part of the string is always the same, but the middle part changes, like this:
id first time i forward the message: aaaaaa_abc_zzzzz
id second time i forward the message: aaaaaa_def_zzzzz
The doc does not say anything about it... (https://godoc.org/github.com/go-telegram-bot-api/telegram-bot-api)
Do you guys know how to deal with file ids? My goal is to be able to say "ok, I received this photo (or voice, or audio, or video) yet from this or another user"
Thank you for your time
Ve
As a reddit user pointed out here, it is possibile to have the unique id of a file as per v4.5 of the Telegram API https://core.telegram.org/bots/api-changelog#december-31-2019.
I couldn'd find that out because a was reading the Golang implementation godoc and the "unique id" feature is not yet implemented.
I'm going to add it and make a PR.
Related
I want to make a bot to search through a channel and find a random message by a user. To do that, I need to read past messages. I've looked in the documentation and all it says is GET /channels/{channel.id}/messages.
I'm asking: How could I return the contents of a message and the author of the message (if possible).
If you're using discord.py, take a look at channel.history
we have a chat bot that seems to be receiving messages from another bot. we'd like to ignore these messages, as responding to them leads to an infinite loop of ping pong between the two bots.
we were hoping to rely on activity.from.role as documented here, but it seems like that field is never set.
activity.from.id looks something like 28:app:00000000-dfae-4fe1-a068-80fe8fc61f2b_62b732f7-fc71-40bc-b27d-35efcb000000, and we are thinking that the only way to identify the account as a bot is by detecting the :app: in these IDs. this is sub-optimal, as this ID format is not part of the official API and could change at any time.
that said, how should we detect if an activity event is coming from a bot?
If you've to deal with potential bots from outside your organisation, a simple way could be to keep a dictionary of few last text exchanges indexed by userId or UserName in the Activity object. Then, at each POST received by your bot, check if the received text match fully one of the precedent message entries in this dictionary. If it is the case, then mark the related userId/UserName as a candidate for the bot role but continue to check further text exchanges in case a non bot user just said hi twice.
If the few following further exchanges doesn't meet anymore the full match requirement, unmark the userId/UserName as a potential bot. If there is marked UserId/UserName as candidate for bot role, apply the bot role to them if there's no more further exchanges past the full match entry or after a delay of your choice. For the latter, it might be useful to provoke a last text exchange after the delay to decide.
For the Watson/Eliza kind of bots, i recommended to check the speed of the exchanges, as far as i know, no human being can exchange more than twenty messages per second.
I'm trying to post a message to a Slack channel each time we receive a confirmed booking via email through Airbnb.
Tried Zapier, by scanning new emails with the subject "Reservation confirmed" sent to our Microsoft Outlook email. If the email has that subject then the zap should posts its contents (body) in the channel. However, the first step (trigger) doesn't recognize new emails.
This is what the Zap looks like:
Step 1: check if a new email is received in Outlook ==> this is the test never passes, because it can't find sample data.
Step 2: filter emails that contain the subject Reservation confirmed (in Dutch)
Step 3: post a message in a Slack channel
Your filter step has "text contains" option followed by the words. While that is logical from a human standpoint it can cause some problems with zapiers filter. Try filtering for each word separately like so:
Subject Contains(text) yourFirstWord
AND
Subject Contains(text) yourSecondWord
This will clear up your filter problem.
Also, double check that subject is not something you typed in but that it is the actual outlook output variable.
If it passes through the filter and still doesn't get to slack then the issue is elsewhere. You may want to post sample data if that doesn't work because it could be that the subject line has hidden whitespace (rare but has happened to me) or other values that is making it filter out. If that's the case I'll edit and update this answer.
I am creating a Node/Express Webapp that would mirror a user's calendar. It would get a notification for every change in the users calendar, and would update the DB with the latest of that user's calendar.
Lets assume that we want to monitor john.doe#gmail.com. Kindly tell me if this is the best (and only) way to do it:
Set up for Push notification - While doing so, we provide (amongst other fields):
token - A plain-text that would be echoed back. This is where I can put something like 'calOwner=john.doe#gmail.com'
id - A UUID channel id
Upon every change, my webhook will get a push notification that would contain:
token : calOwner=john.doe#gmail.com
id : the channelId - I dont understand if this field alone can be used to trace this notification message back to john.doe#gmail.com
Now that I know john.doe#gmail.com has changed, I would do a list with a synchToken. This will return me the change in john's calendar since last synch
What baffles me here is that the seemingly important fields channelId and resourceId (which appears as x-goog-resource-id in the push notification header) are useless, and the only field that ties the push message to list is an optional plain-text field token .
Kindly tell me if this is the only way to track a user's calendar.
UPDATE
Thanks #KENdi for the answer.
My struggle was with the point that simply looking at a push notification message, there is no way to trace it back to john.doe#gmail.com . I now understand why such is the case, that a push notification does not contain the calendarId, but the resourceId instead (which, in plain terms is the event object). It is so because an event can be associated with multiple calendars, and hence multiple calendarIds. Hence, it is the subscriber's responsibility to maintain association of the channel to the calendarId that he had used to create the channel at the first place.
Yes, you are correct, you need the calendar push notification, to notify you about all the changes happened in the Google Calendar.
The purpose of X-Goog-Resource-ID is an opaque value that identifies the watched resource. And this ID is stable across API versions.
Check this SO question to know more about the purpose of X-Goog-Resource-Id.
A web application sends an email on behalf of a UserA to UserB, using the new Gmail API (Users.messages: send).
The synchronous response contains threadId, messageId which are stored in the database.
We then query the history API for any changes in user's inbox (Users.history: list).
Is there an efficient way to get all the updates since last sync (new replies, read/unread changes)?
One implementation that we tried was to filter the history API results through a custom label. Unfortunately, we noticed that once a thread/message is tagged with a specific label any subsequent responses are not labeled automatically and new replies are not included in the history API response.
A second approach was to query threads using gmail advanced search for a particular label and date (e.g. after:2014/08/29 label:MY_LABEL). The problem was that gmail does not return threads that were created before 2014/08/29 but had a reply on that date.
Any scalable suggestions would be greatly appreciated.
Not sure I understand here, users.history.list was made exactly for this. Given a previous historyId, you can then call history.list(previousHistoryid), iterate through the results to find all the message Ids that have been updated since the previous historyId. Then call messages.get() on all of those--for any messages you already knew about you can just call format=MINIMAL (to see label updates), and for new messages you can use a different format to get the message content if you need it.