Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SlackDeleteLast Script #30

Open
SlackerP opened this issue Jul 1, 2015 · 5 comments
Open

SlackDeleteLast Script #30

SlackerP opened this issue Jul 1, 2015 · 5 comments

Comments

@SlackerP
Copy link

SlackerP commented Jul 1, 2015

The SlackDeleteLast script doesn't work for two reasons:

I can't think of a workaround.

@PeteGoo
Copy link
Member

PeteGoo commented Jul 1, 2015

Good point. This is a leftover of the pre-bot API days.

The original intention was to allow anyone to delete bot entries from risky things like the Urban DIctionary script.

@grantbowering
Copy link

This script is still very useful...
I guess the compilation error is because mmbot has a 6.0 version of Newtonsoft.Json that it references in Core, both brains, and a couple other places, and the version being resolved by NuGet is a 4.5 version (it was 5.0.8 in my packages dir)... I don't know what specified to resolve that version (did it come from --init?), but I just cut it out of my packages lib and then the script loaded fine.
To the latter point, this doesn't have to rely on search.messages; the same thing can be accomplished using channels.history, which is still available to bots. Of course, if its last message isn't in the last n messages then it won't find anything to delete, but usually people would be running this command immediately after something came up that needs deleting... (in my case, it was a "cat 100"... sigh.)
Let me see if I can adapt this to work with channels.history instead of search.messages.

@SlackerP
Copy link
Author

I managed to get it to work, giving a user token for the token parameter in the request will make it work because its not using a bot token, however there's around 20 seconds delay for a message to be archived in Slack which means if you do undo command few seconds after a new post from the bot, it will not delete that last post it will delete a message before it that was archived previously.

@grantbowering
Copy link

I re-wrote it to use channels.history and it works great for me, and I'm not experiencing any kind of delay...
The only problem is that the bot user's slack ID (not the user name, but an alphanumeric key Slack assigns) is required in order to filter the results, and I can't see any way that a script can get access to that (it's saved as a private field in the adapter, but not exposed anywhere). So I had to add a config variable for that. And I don't know how someone would get a hold of that other than manually firing a Slack API request to look it up.
For that reason, I don't think I'll share my version unless someone requests it... or unless I can go ahead and add a property to Robot or some other global storage area to store the Slack user ID somewhere retrievable. Unless I'm missing something; is there a place where adapter-specific information can be stored and made available to scripts?

@PeteGoo
Copy link
Member

PeteGoo commented Jul 10, 2015

Hi @grantbowering I would advise opening the PR with a label of DoNotMerge and explain the issues in the PR notes. I or someone else can then have a look and see if we can help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants