diff --git a/license b/license index e7af2f7..fa7ceba 100644 --- a/license +++ b/license @@ -1,6 +1,6 @@ MIT License -Copyright (c) Sindre Sorhus (sindresorhus.com) +Copyright (c) Sindre Sorhus (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: diff --git a/notification_center.py b/notification_center.py index 0945a89..39250ea 100644 --- a/notification_center.py +++ b/notification_center.py @@ -9,7 +9,7 @@ SCRIPT_NAME = 'notification_center' SCRIPT_AUTHOR = 'Sindre Sorhus ' -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') @@ -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') diff --git a/readme.md b/readme.md index b447bf5..14a6284 100644 --- a/readme.md +++ b/readme.md @@ -4,7 +4,6 @@ > [WeeChat](https://weechat.org) script to pass highlights and private messages to the macOS Notification Center - ## Install ### Script center @@ -20,38 +19,37 @@ - Copy or symlink `weechat.png` to `~/.weechat/weechat.png` - Copy or symlink `notification_center.py` into `~/.weechat/python/autoload/` - ## Options ### show_highlights -Default: `'on'`
-Values: `'on'`, `'off'` +Default: `'on'`\ +Values: `'on'` `'off'` ### show_private_message -Default: `'on'`
-Values: `'on'`, `'off'` +Default: `'on'`\ +Values: `'on'` `'off'` ### show_message_text -Default: `'on'`
-Values: `'on'`, `'off'` +Default: `'on'`\ +Values: `'on'` `'off'` ### sound -Default: `'off'`
-Values: `'on'`, `'off'` +Default: `'off'`\ +Values: `'on'` `'off'` ### sound_name -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/`. +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`
-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. @@ -59,28 +57,28 @@ The app bundle ID can be found in `/Applications/.app/Contents/Info. ### ignore_old_messages -Default: `'off'`
-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'`
-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: `''`
+Default: `''`\ Values: Comma-separated list of channel names Channels in this list will trigger a notification on every message received. ### tags -Default: `''`
+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.