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

[Documentation] `slack-message-custom-notifier` object arguments #120

Open
FrancisMurillo opened this issue Oct 13, 2016 · 2 comments

Comments

@FrancisMurillo
Copy link

commented Oct 13, 2016

Hey dood.

Many thanks that you fixed #109 , it helped me view my slack and IRC messages in one buffer.

I just want to point out when using slack-message-custom-notifier, the arguments are not plain text/string as in you can plug it in alert but objects. So in order for me to get the team, room and message; I had to copy the code from the original alert notification and plug in the correct parameters.

I have no problem that the arguments are objects, but rather I had to go look at the source just to figure what they were. So maybe some documentation on the API objects might alleviate this confusion in using the custom notifier.

Either way, good job.

@stevenmccord

This comment has been minimized.

Copy link

commented Jun 2, 2017

@FrancisMurillo @yuya373 is there an example of this? I was trying to setup an alert on some custom text in a specific channel. I tried straight strings, but then stumbled upon this. Thanks!

@FrancisMurillo

This comment has been minimized.

Copy link
Author

commented Jun 3, 2017

My use case is to use the fringe alert instead of the popup since I find it somewhat mousy. As a fallback, I would also like it to be logged and displayed in the minibuffer with some color. I copied the base code and modified it accordingly:

    (defun fn/slack-message-custom-notifier (message room team)
      "My custom notication for slack given MESSAGE, ROOM and TEAM.
What I do is use the fringe to notify me instead of `libnotify'."
      (when (and (not (slack-message-minep message team))
                 (or (slack-im-p room)
                     (and (slack-group-p room) (slack-mpim-p room))
                     (slack-room-subscribedp room team)
                     (string-match (format "@%s" (plist-get (oref team self) :name))
                                   (or (slack-message-body message team) ""))))
        (let* ((team-name (oref team name))
               (room-name (slack-room-name room))
               (text (slack-message-to-alert message team))
               (user-name (slack-message-sender-name message team))
               (out (fn/chat-log team-name room-name user-name text))) ;; My logging function
          (fn/alert-color out ;; My generic fringe color alert.
                          :category 'phackers 
                          :color "#3a417a"))))

    (setq slack-message-custom-notifier #'fn/slack-message-custom-notifier
          slack-message-custom-delete-notifier #'fn/slack-message-custom-notifier)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.