Skip to content

Commit

Permalink
1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Mar 5, 2020
1 parent 97ef6e6 commit 144168e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 27 deletions.
2 changes: 1 addition & 1 deletion license
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
12 changes: 6 additions & 6 deletions notification_center.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

SCRIPT_NAME = 'notification_center'
SCRIPT_AUTHOR = 'Sindre Sorhus <[email protected]>'
SCRIPT_VERSION = '1.5.0'
SCRIPT_VERSION = '1.5.1'
SCRIPT_LICENSE = 'MIT'
SCRIPT_DESC = 'Pass highlights and private messages to the macOS Notification Center'
WEECHAT_ICON = os.path.expanduser('~/.weechat/weechat.png')
Expand All @@ -36,25 +36,25 @@
weechat.hook_print('', 'irc_privmsg,' + weechat.config_get_plugin('tags'), '', 1, 'notify', '')

def notify(data, buffer, date, tags, displayed, highlight, prefix, message):
# ignore if it's yourself
# Ignore if it's yourself
own_nick = weechat.buffer_get_string(buffer, 'localvar_nick')
if prefix == own_nick or prefix == ('@%s' % own_nick):
return weechat.WEECHAT_RC_OK

# ignore messages from the current buffer
# Ignore messages from the current buffer
if weechat.config_get_plugin('ignore_current_buffer_messages') == 'on' and buffer == weechat.current_buffer():
return weechat.WEECHAT_RC_OK

# ignore messages older than the configured theshold (such as ZNC logs) if enabled
# Ignore messages older than the configured theshold (such as ZNC logs) if enabled
if weechat.config_get_plugin('ignore_old_messages') == 'on':
message_time = datetime.datetime.utcfromtimestamp(int(date))
now_time = datetime.datetime.utcnow()

# ignore if the message is greater than 5 seconds old
# Ignore if the message is greater than 5 seconds old
if (now_time - message_time).seconds > 5:
return weechat.WEECHAT_RC_OK

# passing `None` or `''` still plays the default sound so we pass a lambda instead
# Passing `None` or `''` still plays the default sound so we pass a lambda instead
sound = weechat.config_get_plugin('sound_name') if weechat.config_get_plugin('sound') == 'on' else lambda:_
activate_bundle_id = weechat.config_get_plugin('activate_bundle_id')

Expand Down
38 changes: 18 additions & 20 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

> [WeeChat](https://weechat.org) script to pass highlights and private messages to the macOS Notification Center

## Install

### Script center
Expand All @@ -20,67 +19,66 @@
- Copy or symlink `weechat.png` to `~/.weechat/weechat.png`
- Copy or symlink `notification_center.py` into `~/.weechat/python/autoload/`


## Options

### show_highlights

Default: `'on'`<br>
Values: `'on'`, `'off'`
Default: `'on'`\
Values: `'on'` `'off'`

### show_private_message

Default: `'on'`<br>
Values: `'on'`, `'off'`
Default: `'on'`\
Values: `'on'` `'off'`

### show_message_text

Default: `'on'`<br>
Values: `'on'`, `'off'`
Default: `'on'`\
Values: `'on'` `'off'`

### sound

Default: `'off'`<br>
Values: `'on'`, `'off'`
Default: `'off'`\
Values: `'on'` `'off'`

### sound_name

Default: `'Pong'`<br>
Values: `'Basso'`, `'Blow'`, `'Bottle'`, `'Frog'`, `'Funk'`, `'Glass'`, `'Hero'`, `'Morse'`, `'Ping'`, `'Pop'`, `'Purr'`, `'Sosumi'`, `'Submarine'`, `'Tink'`, but can really be anything that has an aptly named sound file in `/System/Library/Sounds/`, `/Library/Sounds/`, or `~/Library/Sounds/`.
Default: `'Pong'`\
Values: `'Basso'` `'Blow'` `'Bottle'` `'Frog'` `'Funk'` `'Glass'` `'Hero'` `'Morse'` `'Ping'` `'Pop'` `'Purr'` `'Sosumi'` `'Submarine'` `'Tink'`, but can really be anything that has an aptly named sound file in `/System/Library/Sounds/`, `/Library/Sounds/`, or `~/Library/Sounds/`.

### activate_bundle_id

Default: `com.apple.Terminal`<br>
Values: `'com.apple.Terminal'`, `'com.googlecode.iterm2'` or any bundle ID that your terminal uses.
Default: `com.apple.Terminal`\
Values: `'com.apple.Terminal'` `'com.googlecode.iterm2'` (or any bundle ID that your terminal uses)

App to activate when the notification is clicked.

The app bundle ID can be found in `/Applications/<MyTerminal>.app/Contents/Info.plist`, right below the `CFBundleIdentifier` key.

### ignore_old_messages

Default: `'off'`<br>
Values: `'on'`, `'off'`
Default: `'off'`\
Values: `'on'` `'off'`

Determines whether old messages, such as log playbacks, will trigger notifications or not.

### ignore_current_buffer_messages

Default: `'off'`<br>
Values: `'on'`, `'off'`
Default: `'off'`\
Values: `'on'` `'off'`

Determines whether messages from the current buffer should trigger notifications or not. This is especially useful if you use [wee-slack](https://github.com/wee-slack/wee-slack) and receive notifications for messages they send, as discussed in [#22](https://github.com/sindresorhus/weechat-notification-center/issues/22).

### channels

Default: `''`<br>
Default: `''`\
Values: Comma-separated list of channel names

Channels in this list will trigger a notification on every message received.

### tags

Default: `''`<br>
Default: `''`\
Values: Comma-separated list of tags

Additional [message tags](https://weechat.org/files/doc/stable/weechat_user.en.html#lines_tags) that can trigger notifications. This can be used in combination with [`weechat.look.highlight_tags`](https://weechat.org/files/doc/stable/weechat_user.en.html#option_weechat.look.highlight_tags) to generate custom notifications.
Expand Down

0 comments on commit 144168e

Please sign in to comment.