diff options
| author | Simeon Simeonov | 2019-01-30 12:32:33 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2019-01-30 12:32:33 +0100 |
| commit | 9e3aee8c039b4b42232672762c2ea7cba097ce47 (patch) | |
| tree | 6ba54b9ace6b109afb1f037221b7959d2b96bbb2 | |
| parent | a9fa2aa298f179095313402eac255430fb7bad79 (diff) | |
Cleanup a bad idea (possible bug)
| -rwxr-xr-x | beinc_poller.py | 1 | ||||
| -rw-r--r-- | beinc_weechat.py | 36 |
2 files changed, 7 insertions, 30 deletions
diff --git a/beinc_poller.py b/beinc_poller.py index f41a6b6..624cd24 100755 --- a/beinc_poller.py +++ b/beinc_poller.py | |||
| @@ -117,6 +117,7 @@ def poll_notifications(scheduler, args): | |||
| 117 | display_notification(args, | 117 | display_notification(args, |
| 118 | entry.get('title', ''), | 118 | entry.get('title', ''), |
| 119 | entry.get('message', '')) | 119 | entry.get('message', '')) |
| 120 | response.close() | ||
| 120 | scheduler.enter(args.frequency, | 121 | scheduler.enter(args.frequency, |
| 121 | 1, | 122 | 1, |
| 122 | poll_notifications, | 123 | poll_notifications, |
diff --git a/beinc_weechat.py b/beinc_weechat.py index b367ef6..132a22a 100644 --- a/beinc_weechat.py +++ b/beinc_weechat.py | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
| 2 | 2 | ||
| 3 | # Blackmore's Enhanced IRC-Notification Collection (BEINC) v3.0 | 3 | # Blackmore's Enhanced IRC-Notification Collection (BEINC) v3.0 |
| 4 | # Copyright (C) 2013-2018 Simeon Simeonov | 4 | # Copyright (C) 2013-2019 Simeon Simeonov |
| 5 | 5 | ||
| 6 | # This program is free software: you can redistribute it and/or modify | 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | # it under the terms of the GNU General Public License as published by | 7 | # it under the terms of the GNU General Public License as published by |
| @@ -24,6 +24,8 @@ import socket | |||
| 24 | import ssl | 24 | import ssl |
| 25 | import sys | 25 | import sys |
| 26 | 26 | ||
| 27 | import weechat | ||
| 28 | |||
| 27 | PY2 = sys.version_info[0] == 2 | 29 | PY2 = sys.version_info[0] == 2 |
| 28 | PY3 = sys.version_info[0] == 3 | 30 | PY3 = sys.version_info[0] == 3 |
| 29 | 31 | ||
| @@ -34,8 +36,6 @@ else: | |||
| 34 | from urllib import urlencode | 36 | from urllib import urlencode |
| 35 | from urllib2 import urlopen | 37 | from urllib2 import urlopen |
| 36 | 38 | ||
| 37 | import weechat | ||
| 38 | |||
| 39 | 39 | ||
| 40 | __author__ = 'Simeon Simeonov' | 40 | __author__ = 'Simeon Simeonov' |
| 41 | __version__ = '3.0' | 41 | __version__ = '3.0' |
| @@ -395,6 +395,9 @@ def beinc_cmd_target_handler(cmd_tokens): | |||
| 395 | beinc_prnt('beinc target [ list | enable <name> | disable <name> ]') | 395 | beinc_prnt('beinc target [ list | enable <name> | disable <name> ]') |
| 396 | return weechat.WEECHAT_RC_OK | 396 | return weechat.WEECHAT_RC_OK |
| 397 | if cmd_tokens[0] == 'list': | 397 | if cmd_tokens[0] == 'list': |
| 398 | beinc_prnt('--- Globals ---') | ||
| 399 | for key, value in global_values.items(): | ||
| 400 | beinc_prnt('{key} -> {value}'.format(key=key, value=str(value))) | ||
| 398 | beinc_prnt('--- Targets ---') | 401 | beinc_prnt('--- Targets ---') |
| 399 | for target in target_list: | 402 | for target in target_list: |
| 400 | beinc_prnt(str(target)) | 403 | beinc_prnt(str(target)) |
| @@ -473,13 +476,6 @@ def beinc_privmsg_handler(data, signal, signal_data): | |||
| 473 | # priv messages are handled here | 476 | # priv messages are handled here |
| 474 | if not global_values['global_private_messages_policy']: | 477 | if not global_values['global_private_messages_policy']: |
| 475 | return weechat.WEECHAT_RC_OK | 478 | return weechat.WEECHAT_RC_OK |
| 476 | p_messages_policy = global_values['global_private_messages_policy'] | ||
| 477 | if p_messages_policy == BEINC_POLICY_LIST_ONLY and \ | ||
| 478 | '{0}.{1}'.format( | ||
| 479 | ph_values['server'], | ||
| 480 | ph_values['source_nick'].lower() | ||
| 481 | ) not in global_values['global_nicks']: | ||
| 482 | return weechat.WEECHAT_RC_OK | ||
| 483 | for target in target_list: | 479 | for target in target_list: |
| 484 | if not target.enabled: | 480 | if not target.enabled: |
| 485 | continue | 481 | continue |
| @@ -494,14 +490,6 @@ def beinc_privmsg_handler(data, signal, signal_data): | |||
| 494 | # notify messages are handled here | 490 | # notify messages are handled here |
| 495 | if not global_values['global_notifications_policy']: | 491 | if not global_values['global_notifications_policy']: |
| 496 | return weechat.WEECHAT_RC_OK | 492 | return weechat.WEECHAT_RC_OK |
| 497 | notifications_policy = global_values['global_notifications_policy'] | ||
| 498 | if notifications_policy == BEINC_POLICY_LIST_ONLY and ( | ||
| 499 | '{0}.{1}'.format( | ||
| 500 | ph_values['server'], | ||
| 501 | ph_values['channel'].lower() | ||
| 502 | ) not in global_values['global_chans'] | ||
| 503 | ): | ||
| 504 | return weechat.WEECHAT_RC_OK | ||
| 505 | for target in target_list: | 493 | for target in target_list: |
| 506 | if not target.enabled: | 494 | if not target.enabled: |
| 507 | continue | 495 | continue |
| @@ -516,14 +504,6 @@ def beinc_privmsg_handler(data, signal, signal_data): | |||
| 516 | # chan messages are handled here | 504 | # chan messages are handled here |
| 517 | if not global_values['global_notifications_policy']: | 505 | if not global_values['global_notifications_policy']: |
| 518 | return weechat.WEECHAT_RC_OK | 506 | return weechat.WEECHAT_RC_OK |
| 519 | c_messages_policy = global_values['global_channel_messages_policy'] | ||
| 520 | if c_messages_policy == BEINC_POLICY_LIST_ONLY and ( | ||
| 521 | '{0}.{1}'.format( | ||
| 522 | ph_values['server'], | ||
| 523 | ph_values['channel'].lower() | ||
| 524 | ) not in global_values['global_chans'] | ||
| 525 | ): | ||
| 526 | return weechat.WEECHAT_RC_OK | ||
| 527 | for target in target_list: | 507 | for target in target_list: |
| 528 | if not target.enabled: | 508 | if not target.enabled: |
| 529 | continue | 509 | continue |
| @@ -550,8 +530,6 @@ def beinc_init(): | |||
| 550 | 530 | ||
| 551 | # global chans/nicks sets are used to speed up the filtering | 531 | # global chans/nicks sets are used to speed up the filtering |
| 552 | global_values = dict() | 532 | global_values = dict() |
| 553 | global_values['global_chans'] = set() | ||
| 554 | global_values['global_nicks'] = set() | ||
| 555 | target_list = list() | 533 | target_list = list() |
| 556 | custom_error = '' | 534 | custom_error = '' |
| 557 | global_values['global_channel_messages_policy'] = False | 535 | global_values['global_channel_messages_policy'] = False |
| @@ -586,8 +564,6 @@ def beinc_init(): | |||
| 586 | except Exception as e: | 564 | except Exception as e: |
| 587 | beinc_prnt('Unable to add target: {0}'.format(e)) | 565 | beinc_prnt('Unable to add target: {0}'.format(e)) |
| 588 | continue | 566 | continue |
| 589 | global_values['global_chans'].update(new_target.chans) | ||
| 590 | global_values['global_nicks'].update(new_target.nicks) | ||
| 591 | if new_target.channel_messages_policy: | 567 | if new_target.channel_messages_policy: |
| 592 | global_values['global_channel_messages_policy'] = True | 568 | global_values['global_channel_messages_policy'] = True |
| 593 | if new_target.private_messages_policy: | 569 | if new_target.private_messages_policy: |
