Jump to content

frankspin

Member
  • Posts

    71
  • Joined

  • Last visited

  • Days Won

    7

Posts posted by frankspin

  1. Hi. Great workflow, big thanks! I have one issue, when i type "slf" (Search Files) i get error message. Slack account is free, maybe it can't search in free accounts?

    xY4YlKl.png

     

    Just pushed a fix to GitHub and packal. There was a key error but it should be fixed. Let me know.

    Hello! Is Slackfred already Alfred 3-ready? Because it is not working for me with Alfred 3. Thank you!

     

    Can you specify what's not working?

  2. @frankspin -

     

    I've recently discovered that the Slack URL scheme appears to be working on the Mac. Basically, slack://channel?id={CHANNEL-ID or IM-ID}&team={TEAM-ID} will open the Slack app in the channel selected. I'm wondering if there's a way to modify Slackfred to take advantage of this versus the script that triggers the Quick Switcher? I took a look into the code, but it's a bit beyond what I understand.

    In a nutshell, what I'd love to do is type "slk" into Alfred to search for users or channels. Once I select one, I'll need to pass the Channel ID or IM ID (note: the URL scheme needs the IM ID that's tied to the user, not the User ID, in order to work for chatting with individual users - https://api.slack.com/methods/im.list/test)into the URL. 

     

    Any thoughts? Thanks!

     

    This should be in the workflow already. Make sure you have the latest version.

  3. Hey frankspin,

     

    I think Slack have maybe changed where tokens are/some wording - should we be using test tokens (https://api.slack.com/docs/oauth-test-tokens) for this? 

     

    Thanks very much,

     

    James

     

     

    Hi frankspin,

     

    I too would like to know the answer to jwhitmarsh's question. When slackfred sends me to https://api.slack.com/web, all is see is a button that allows me to generate test tokens. Someone at my work suggested creating a slack bot and using its API token, but that's not ideal, since the bot will be a completely separate user.

     

    Can you please provide some input on this?

     

    Thanks!

     

    Michael

     

     

    Yep, they should work fine.

  4. Hey frankspin,

     

    I'm really liking the development on the slack workflow! I was wondering if you will support direct messaging on the workflow any time soon? If not, I don't mind looking into it, unless you've already started.

     

    Thanks,

    Nolan

     

     

     

    Feel free to add it. The current functionality for sending messages to channels isn't ideal, but it gets the job done. When I started working on this I had a lot more free time, but since my time has been a bit limited.

     

    My hope/plan was to implement some kind of DB or text file feature so that an API request wasn't required every single time and you can more easily navigate your stuff. It's just a time thing for me.

  5. @frankspin - I tried with the updated file and still get the same problem. However today, I noticed that (sort of relevant) results flickered for a second before reverting back to default engine search (happened also before I updated). So it's doing something right before getting messed up (sls worked I think, not slim).

     

    Can you open the debug menu and run slim? I should clarify a bit more, but when using slim it should be used with their chat name and not their real name. So if your real name is John Doe but your chat name is Maddog, search for maddog.

  6. Hit the same problem. The issue is that the codebase is behind your GitHub code. The slackfred-search.py file attempts to import requests and then tries to use it once for a GET requests. The other time, you use the web.py module from the Alfred-Workflow library. Your GitHub code doesn't have this issue. All you need to do is update the Packal download with the up-to-date codebase.

     

    - - -

     

    PS. Nice workflow!

     

    Good catch! I just updated the workflow file to include the library. Can you give it another go? https://github.com/fspinillo/slackfred/blob/master/workflow/Slackfred.alfredworkflow

  7. Has anyone made a workflow to take something from slack and send it to Things?

     

    Working with: http://support.culturedcode.com/customer/portal/articles/1625470-creating-to-dos-with-a-launcher

     

    You could probably add an additional modifier to the workflow that uses applescript. For example: if you use 'slf' you hold 'ctrl' while clicking a result you can have Applescript relaunch Alfred with '+' and paste in the result.

  8. Hey,

     

    Been using this for a few days, using mostly 'slk'. Very useful!

     

    Few things:

     

    1. Both 'slim' and 'sls' don't work for me, as soon as I type the command, after I hit space, it just reverts to searching the default search engines. Not sure if I'm supposed to type username or the query, but neither seemed to work.

     

    2. Sometimes someone messages me and I just want to quickly reply 'ok' or '2 min', how feasible is it to just type the name and quick message and send, without ever activating slack? If not feasible directly, would it be possible to use applescript to mimic this? Switch to user like 'slk', type the message, hit enter and then cmd+tab back to wherever I was before?

     

    Thanks! Great idea and execution!

     

    1. Try it but without hitting space after you enter a name or query. Admittedly what I'm doing isn't the fastest or most feasible solution so it can sometimes mess up or hang for a bit

     

    2. Applescript is hard to use right now with multi-orgs since I cannot account for how they're set up. I asked the SlackAPI twitter about callback urls / deep linking in the desktop app and it's currently not there. Having it would make this kind of thing a lot easier to pull off. As for sending messages in general I want to eventually look into sending messages I just haven't had a ton of time to do so. I know it would be through Webhooks I just need to find sometime.

  9. Bumping this for those of you asking for multi team support as it's now available. A few caveats though:

     

    1. Speed isn't the best for certain workflow options. I'll be working to improve

    2. Getting support for teams within the desktop client is tough. Since I have no way of knowing the order your teams were added it's hard for me to build that functionality in. Until Slack offers proper deep linking with the client I wont be able to move forward there.

    3. With #2 stated, the command `slk` isn't terribly effective with multiple teams since it's using the client. I left it in there for those who are on single teams.

  10. Thanks for the feedback. I'll go through and make some adjustments.

     

     

    Is there a reason you're using both workflow.web and requests? If you need requests, there's little point using workflow.web, too: it's just a crappy version of requests.

     

    For some reason that search query was not working under .web so I was using requests

     

     

    You make two HTTP requests for each API query (one to verify auth, one to get the actual data). Doesn't the API return an authentication error if you try to call it without being authorised? The workflow would probably run a fair bit more quickly if it only needs to make one request per API call.

     

    It will return 'ok': False but I use some of the info in the auth check in the results I'm returning. The normal calls don't return data like team name so I have to make that call anyway

     

     

    It's kinda bad form to have your functions doing two unrelated things (i.e. retrieving data and sending output, but only sometimes).

     

    I had a feeling this might look bad. I was splitting them with the intention of eventually trying to turn some of it into a wrapper to learn OOP a bit.

     

     

    You could also speed things up a fair bit by making the API call for each key in parallel in threads (if the API permits that).

     

    I realize iterating through a loop for each key probably isn't the best idea and in some cases speed would be a huge help. I'll have to look into how to properly do threading.

  11. Woo, haven't posted here in a bit.

     

    Just to follow up to the multiple keys question I asked a while back, I did come up with a solution. It involces saving each key comma seperated, then splitting them out. Not the most ideal solution, but it's working for me.

     

    A situation I'm running into now though is properly iterating through my for loops. In every other work flow this is working fine, but I think because this one is relying on a search endpoint it's hanging me up. What I'm trying to do is let someone enter a search query, get the results, then display all the results. For some reason it's only displaying 1, then after a few seconds updates to show the last result. I can't seem to figure out why it's only showing the one. I've tried using sleeps to prevent it from querying the search before someone finishes, but that isn't working.

    import sys
    import argparse
    import requests
    from workflow import Workflow, web, PasswordNotFound
    
    
    def slack_keys():
        wf = Workflow()
        try:
            slack_keys = wf.get_password('slack_api_key')
        except PasswordNotFound:
            wf.add_item(title='No API key set. Please run slt',
                        valid=False)
            wf.send_feedback()
            return 0
        keys = slack_keys.split(",")
    
        return keys
    
    def search_slack(keys, query):
        wf = Workflow()
        search_results = []
        for key in keys:
            api_key = str(key)
            slack_auth = web.get('https://slack.com/api/auth.test?token=' + api_key + '&pretty=1').json()
            if slack_auth['ok'] is False:
                wf.add_item('Authentication failed.'
                            'Try saving your API key again',
                            valid=False)
                wf.send_feedback()
            else:
                results = requests.get('https://slack.com/api/search.messages?token=' + api_key + '&query=' + query +
                                  '&count=10&pretty=1').json()
                if results['messages']['total'] > 0:
                    for result in results['messages']['matches']:
                        if result['type'] == 'message':
                            search_results.append({'text': result['text'], 'channel': result['channel']['name'],
                                                   'user': result['username'], 'team': slack_auth['team'],
                                                   'link': result['permalink']})
                else:
                    search_results.append({'text': 'False', 'team': slack_auth['team']})
    
        return search_results
    
    def main(wf):
    
        parser = argparse.ArgumentParser()
        parser.add_argument('query', nargs='?', default=None)
        args = parser.parse_args(wf.args)
    
        query = args.query
    
        search_results = search_slack(keys=slack_keys(), query=query)
    
        for results in search_results:
            if results['text'] == 'False':
                wf.add_item(title='No search results found',
                            subtitle=results['team'],
                            valid=False)
            else:
                wf.add_item(title=results['text'],
                            subtitle='%s - %s - %s' % (results['user'], results['channel'], results['team']),
                            arg=results['link'],
                            valid=True)
    
            wf.send_feedback()
    
    if __name__ == u"__main__":
        wf = Workflow()
        sys.exit(wf.run(main))
    
  12. Simulating keypresses is easy with Applescript -- see the script I just posted to close a window for an example.

     

    I should have expanded further, but I mean how with some workflows you have to hit enter to finish whatever it's doing. An example would be with Pinboard: you can search, but you need to highlight the item and hit enter. It's not so much for triggering them via a script, but for allowing more interaction with workflows that use them. IE: After searching for an item in Pinboard holding ctrl would delete it instead of opening it

  13. First off let me start by saying congratulations to the Alfred team for getting this shipped. I wasn't expecting this level of completion for v1, but it's pretty well stocked.

     

    Now for the feedback:

    Receving user input via the iOS app would be hugely beneficial. For example in my Slack worflow I let people set status with 'active' or 'away', but can't allow this input in the app. If I walk away from the computer it'd be great to set that status without having to go back.

     

    Simulating key press (enter/cmd/ctrl) would also be pretty great, but understand there could be limitations

     

    I noticed if you build a remote trigger, add it to "Remote" and then rename it the trigger wont work anymore. I think it'd be ideal if names and adjustments were reflected without needing to add/remove.

     

    Pie in the sky request here but the ability to have workflows output back to the app/phone. Example: In my Digital Ocean workflow it checks status and returns some stats. My thinking is rather than just display it in the desktop, you can modify an output to format the results back to the app. Again, the idea being running certain workflows while away from the computer for an extended period of time.

×
×
  • Create New...