Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Commits on Oct 12, 2012
@webvictim webvictim Added buffer names to notifications
I like buffer names in my notifications.
9e5e3f9
@webvictim webvictim Added "ignore_active_window" as an option
Notifications in windows where you're already active and not away seem
a little superfluous
3a27b5a
Showing with 21 additions and 16 deletions.
  1. +21 −16 growl.py
View
37 growl.py
@@ -53,6 +53,7 @@
'show_channel_topic': 'on',
'show_dcc': 'on',
'show_upgrade_ended': 'on',
+ 'ignore_active_window': 'on',
'sticky': 'off',
'sticky_away': 'on',
'hostname': '',
@@ -172,17 +173,17 @@ def cb_notify_upgrade_ended(data, signal, signal_data):
return weechat.WEECHAT_RC_OK
-def notify_highlighted_message(prefix, message):
+def notify_highlighted_message(prefix, message, buffer_name):
'''Notify on highlighted message.'''
if weechat.config_get_plugin("show_highlighted_message") == "on":
growl_notify(
'Highlight',
- 'Highlighted Message',
+ "Highlight in {0}".format(buffer_name),
"{0}: {1}".format(prefix, message),
priority=2)
-def notify_public_message_or_action(prefix, message, highlighted):
+def notify_public_message_or_action(prefix, message, highlighted, buffer_name):
'''Notify on public message or action.'''
if prefix == ' *':
regex = re.compile(r'^(\w+) (.+)$', re.UNICODE)
@@ -193,7 +194,7 @@ def notify_public_message_or_action(prefix, message, highlighted):
notify_public_action_message(prefix, message, highlighted)
else:
if highlighted:
- notify_highlighted_message(prefix, message)
+ notify_highlighted_message(prefix, message, buffer_name)
elif weechat.config_get_plugin("show_public_message") == "on":
growl_notify(
'Public',
@@ -201,12 +202,12 @@ def notify_public_message_or_action(prefix, message, highlighted):
'{0}: {1}'.format(prefix, message))
-def notify_private_message_or_action(prefix, message, highlighted):
+def notify_private_message_or_action(prefix, message, highlighted, buffer_name):
'''Notify on private message or action.'''
regex = re.compile(r'^CTCP_MESSAGE.+?ACTION (.+)$', re.UNICODE)
match = regex.match(message)
if match:
- notify_private_action_message(prefix, match.group(1), highlighted)
+ notify_private_action_message(prefix, match.group(1), highlighted, buffer_name)
else:
if prefix == ' *':
regex = re.compile(r'^(\w+) (.+)$', re.UNICODE)
@@ -214,10 +215,10 @@ def notify_private_message_or_action(prefix, message, highlighted):
if match:
prefix = match.group(1)
message = match.group(2)
- notify_private_action_message(prefix, message, highlighted)
+ notify_private_action_message(prefix, message, highlighted, buffer_name)
else:
if highlighted:
- notify_highlighted_message(prefix, message)
+ notify_highlighted_message(prefix, message, buffer_name)
elif weechat.config_get_plugin("show_private_message") == "on":
growl_notify(
'Private',
@@ -228,7 +229,7 @@ def notify_private_message_or_action(prefix, message, highlighted):
def notify_public_action_message(prefix, message, highlighted):
'''Notify on public action message.'''
if highlighted:
- notify_highlighted_message(prefix, message)
+ notify_highlighted_message(prefix, message, buffer_name)
elif weechat.config_get_plugin("show_public_action_message") == "on":
growl_notify(
'Action',
@@ -237,10 +238,10 @@ def notify_public_action_message(prefix, message, highlighted):
priority=1)
-def notify_private_action_message(prefix, message, highlighted):
+def notify_private_action_message(prefix, message, highlighted, buffer_name):
'''Notify on private action message.'''
if highlighted:
- notify_highlighted_message(prefix, message)
+ notify_highlighted_message(prefix, message, buffer_name)
elif weechat.config_get_plugin("show_private_action_message") == "on":
growl_notify(
'Action',
@@ -249,7 +250,7 @@ def notify_private_action_message(prefix, message, highlighted):
priority=1)
-def notify_notice_message(prefix, message, highlighted):
+def notify_notice_message(prefix, message, highlighted, buffer_name):
'''Notify on notice message.'''
regex = re.compile(r'^([^\s]*) [^:]*: (.+)$', re.UNICODE)
match = regex.match(message)
@@ -257,7 +258,7 @@ def notify_notice_message(prefix, message, highlighted):
prefix = match.group(1)
message = match.group(2)
if highlighted:
- notify_highlighted_message(prefix, message)
+ notify_highlighted_message(prefix, message, buffer_name)
elif weechat.config_get_plugin("show_notice_message") == "on":
growl_notify(
'Notice',
@@ -359,7 +360,7 @@ def notify_dcc_send_failed(match):
# -----------------------------------------------------------------------------
# Utility
# -----------------------------------------------------------------------------
-def set_away_status(prefix, message, highlighted):
+def set_away_status(prefix, message, highlighted, buffer_name):
'''Sets away status for use by sticky notifications.'''
regex = re.compile(r'^\[\w+ \b(away|back)\b:', re.UNICODE)
match = regex.match(message)
@@ -387,14 +388,18 @@ def cb_process_message(
is_public_message = tags.issuperset(
TAGGED_MESSAGES['public message or action'])
buffer_name = weechat.buffer_get_string(wbuffer, 'name')
+ display_count = weechat.buffer_get_integer(wbuffer, 'num_displayed')
dcc_buffer_regex = re.compile(r'^irc_dcc\.', re.UNICODE)
dcc_buffer_match = dcc_buffer_regex.match(buffer_name)
highlighted = False
if highlight == "1":
highlighted = True
+ # Is this buffer currently displayed, with the 'ignore_active_window' setting on and the user not away?
+ if display_count > 0 and weechat.config_get_plugin('ignore_active_window') == 'on' and STATE['is_away'] == False:
+ return weechat.WEECHAT_RC_OK
# Private DCC message identifies itself as public.
if is_public_message and dcc_buffer_match:
- notify_private_message_or_action(prefix, message, highlighted)
+ notify_private_message_or_action(prefix, message, highlighted, buffer_name)
return weechat.WEECHAT_RC_OK
# Pass identified, untagged message to its designated function.
for key, value in UNTAGGED_MESSAGES.items():
@@ -405,7 +410,7 @@ def cb_process_message(
# Pass identified, tagged message to its designated function.
for key, value in TAGGED_MESSAGES.items():
if tags.issuperset(value):
- functions[DISPATCH_TABLE[key]](prefix, message, highlighted)
+ functions[DISPATCH_TABLE[key]](prefix, message, highlighted, buffer_name)
return weechat.WEECHAT_RC_OK
return weechat.WEECHAT_RC_OK

No commit comments for this range

Something went wrong with that request. Please try again.