I have a slack bot that is sending direct messages to users. I want to add a functionality that will delete the message automatically 10 minutes after it has been sent. Please help.
There is an api that is used to delete chat messages :
https://api.slack.com/methods/chat.delete
For your use case, you need to capture the channel & timestamp details from the response of message that was sent. Once the message is sent, wait for required time and then call 'chat.delete' api to delete the message.
Related
When guildUpdate is detected when updated with a server.
with discordGo
I want my bot to send a message to a channel. So when an authorized person makes changes to the server, I want a message to be sent to a particular channel only once, how can I do that?
Its logic is like an invitation bot. Instead of sending a message when the member logs in, it will only send a notification to a channel when the server is edited (updated). But I don't know as I am new to this coding language. :(
I am trying some stuff about Reliability of message delivery using ConfirmCallback.
So far I've done these:
1.When I send a message, I save it in the db (There is a field called status that indicates whether the message reached the broker successfully). Message id will stored in correlationData.
2.Using ConfirmCallback, if ack, i will update Message#status to success.( I can get message id from CorrelationData )
3.Using timed tasks to find the message that was not sent successfully, and resend.
I wonder why ConfirmCallback#confirm#CorrelationData has only one property id rather than the entire message so that I can resend message immediately.(In this way I don't need to persist messages).
Is there any other way to ensure that the message is sent successfully?
Any Suggestions would be appreciated.
You can sub-class CorrelationData to add the message.
I want to see the last post a bot makes to my channel through the API/https
I tried getUpdates and it only shows messages I sent to the bot. I'd like to see messages the bot broadcasts to my channel
https://api.telegram.org/botxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/getUpdates
The getUpdates method only retrieves messages that are sent to the bot by normal users. Bots cannot see other bot messages, that means it cannot see its own messages. However you can track messages sent by the bot in your code logic. E.g. in Node.js you would do something like:
bot.sendMessage(channelId, "The message sent to the channel").then(ctx => {
// ctx contains the details of the message sent to the channel
// you can do whatever you want with it
});
I have successfully created a bot with and am able to fetch messages from a chat using the getupdates method (long polling).
The getUpdates method is only showing user posted messages (clientside). When I post messages directly using the sendmessage method (serverside) these messages do appear in the chat, but do not in the getUpdates log.
This page https://github.com/LibreLabUCM/teleg-api-bot/wiki/Getting-started-with-the-Telegram-Bot-API#getupdates
states it logs only when "An user messages your bot, either directly or in a group." and some other ways, but the sendMessage way is not mentioned.
I've read a bit on the setwebhook method (push) but am not sure this will fix my issue.
Is this possible?
According to Bot FAQ, bots will not be able to see messages from other bots regardless of mode.
The getUpdates method shows only updates from users, not from the bot itself. This means that when you fetch the new messages with the getUpdates method, the Telegram API will list only the messages sent by the users, not the messages sent by the bot via any method (e.g sendMessage, sendPhoto ...).
To get old messages you can store the entire update (or only the parts of the update you need) for each message (even those sent by the bot with the sendMessage method) in a file or in a database and when you need an old message you can simply fetch it form the database or the files.
I managed to get the bot messages using two bots.
One does the sendMessage method and the other one does the getUpdates method.
#Giolacca9 answer inspired me to try this workaround and it works, "not from the bot itself" :)
I would like to get the notification about the status of the IronWorker task after its finished.
I tried to setup and incoming-webhook, but could not find any way to achieve this.
Update
I know how to setup incoming webhook in slack. I am finding a way to trigger this webhook by IronWorker after its completed. I just don't want to integrate the request code in my worker code.
Any help would be appreciated.
IronWorkers allow you to configure a UDP log feed. They tend to send logs to papertrailapp over this UDP feed. If you have ELK stack then try pointing to that. Most log aggregation frameworks have a detect and notify feature built in. So logentries or papertrail or ELK could then look for a log statement from your worker like DONE and notify you in email/slack/text etc.
If your worker has reached the end of its business logic safely then perhaps it is safe to assume that it can also send a REST request to slack on its own saying i'm done! And that such an action wouldn't be an extra burden or cause any additional failures ... try & see ... then share!
(a) you could queue a notification task in a "notification worker" queue as the last step in your workers ... if you want to reduce the chances of failures or retries caused by the notification code itself.
The current API doesn't show a way to register and receive notifications about worker status from iron.io itself ... it seems only polling based: http://dev.iron.io/worker/reference/api/
So you want to set up incoming webhook in slack. And you want to trigger them when the task is complete.
After registering the incoming webhook in slack, you will get the Webhook URL. Its of the form - https://hooks.slack.com/services/SECRET/SECRET
Now we have to make a post request to this url along with the data.
import requests
import json
url = 'https://hooks.slack.com/services/SECRET/'
payload = {'text': 'Random test',"username": "A slack bot","icon_url": "https://slack.com/img/icons/app-57.png","channel": "#abhinav_rai"}
r = requests.post(url, data=json.dumps(payload))
print r.text
print r.status_code
The Following is the python code to make request to the webhook url. This will post your data in the desired channel.
For more information: Visit https://api.slack.com/incoming-webhooks or comment below.