[triggers] 1.4.7
This commit is contained in:
committed by
Philipp Hörist
parent
1e0add4eef
commit
4f3fd7c8ec
@@ -13,8 +13,8 @@
|
|||||||
"win32"
|
"win32"
|
||||||
],
|
],
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"gajim>=1.4.0"
|
"gajim>=1.5.0"
|
||||||
],
|
],
|
||||||
"short_name": "triggers",
|
"short_name": "triggers",
|
||||||
"version": "1.4.6"
|
"version": "1.4.7"
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,6 @@ from gajim.common.const import STOP_EVENT
|
|||||||
from gajim.common.events import Notification
|
from gajim.common.events import Notification
|
||||||
from gajim.common.events import GcMessageReceived
|
from gajim.common.events import GcMessageReceived
|
||||||
from gajim.common.events import MessageReceived
|
from gajim.common.events import MessageReceived
|
||||||
from gajim.common.events import Notification
|
|
||||||
from gajim.common.helpers import exec_command
|
from gajim.common.helpers import exec_command
|
||||||
from gajim.common.helpers import play_sound_file
|
from gajim.common.helpers import play_sound_file
|
||||||
|
|
||||||
@@ -210,8 +209,8 @@ class Triggers(GajimPlugin):
|
|||||||
@log_result
|
@log_result
|
||||||
def _check_rule_status(self, event, rule: RuleT) -> bool:
|
def _check_rule_status(self, event, rule: RuleT) -> bool:
|
||||||
rule_statuses = rule['status'].split()
|
rule_statuses = rule['status'].split()
|
||||||
our_status = app.connections[event.account].status
|
client = app.get_client(event.account)
|
||||||
if rule['status'] != 'all' and our_status not in rule_statuses:
|
if rule['status'] != 'all' and client.status not in rule_statuses:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -221,7 +220,7 @@ class Triggers(GajimPlugin):
|
|||||||
if rule['tab_opened'] == 'both':
|
if rule['tab_opened'] == 'both':
|
||||||
return True
|
return True
|
||||||
tab_opened = False
|
tab_opened = False
|
||||||
if app.window.get_control(event.account, event.jid):
|
if app.window.chat_exists(event.account, event.jid):
|
||||||
tab_opened = True
|
tab_opened = True
|
||||||
if tab_opened and rule['tab_opened'] == 'no':
|
if tab_opened and rule['tab_opened'] == 'no':
|
||||||
return False
|
return False
|
||||||
@@ -237,14 +236,10 @@ class Triggers(GajimPlugin):
|
|||||||
if rule['tab_opened'] == 'no':
|
if rule['tab_opened'] == 'no':
|
||||||
# Does not apply in this case
|
# Does not apply in this case
|
||||||
return True
|
return True
|
||||||
ctrl = app.window.get_control(event.account, event.jid)
|
chat_active = app.window.is_chat_active(event.account, event.jid)
|
||||||
if not ctrl:
|
if chat_active and rule['has_focus'] == 'no':
|
||||||
# Does not apply in this case
|
|
||||||
return True
|
|
||||||
has_focus = ctrl.has_focus()
|
|
||||||
if has_focus and rule['has_focus'] == 'no':
|
|
||||||
return False
|
return False
|
||||||
elif not has_focus and rule['has_focus'] == 'yes':
|
elif not chat_active and rule['has_focus'] == 'yes':
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user