Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • weechat/scripts
1 result
Show changes
Commits on Source (17)
Loading
Loading
@@ -20,6 +20,9 @@
# (this script requires WeeChat 0.3.0 or newer)
#
# History:
# 2018-04-10, Sébastien Helleu <flashcode@flashtux.org>
# version 0.5: fix infolist_time for WeeChat >= 2.2 (WeeChat returns a long
# integer instead of a string)
# 2016-02-05, ixti
# version 0.4: Add Python3 support
# 2009-12-15, xt
Loading
Loading
@@ -34,7 +37,7 @@ import time
 
SCRIPT_NAME = "buffer_autoclose"
SCRIPT_AUTHOR = "xt <xt@bash.no>"
SCRIPT_VERSION = "0.4"
SCRIPT_VERSION = "0.5"
SCRIPT_LICENSE = "GPL3"
SCRIPT_DESC = "Automatically close inactive private message buffers"
 
Loading
Loading
@@ -73,6 +76,10 @@ def get_last_line_date(buffer):
infolist = w.infolist_get('buffer_lines', buffer, '')
while w.infolist_prev(infolist):
date = w.infolist_time(infolist, 'date')
# since WeeChat 2.2, infolist_time returns a long integer instead of
# a string
if not isinstance(date, str):
date = time.strftime('%F %T', time.localtime(int(date)))
if date != '1970-01-01 01:00:00':
# Some lines like "Day changed to" message doesn't have date
# set so loop until we find a message that does
Loading
Loading
# -*- coding: utf-8 -*-
#
# buffer_swap, version 0.3 for WeeChat version 0.3
# Latest development version: https://github.com/FiXato/weechat_scripts
#
# Swaps given 2 buffers. Requested by kakazza
#
## Example:
# Swaps buffers 3 and 5
# /swap 3 5
#
# Swaps current buffer with the #weechat buffer
# /swap #weechat
#
## History:
### 2011-09-18: FiXato:
#
# * version 0.1: initial release.
# * Allow switching 2 given buffers
#
# * version 0.2: cleanup
# * Made the command example more clear that it requires 2 buffer *numbers*
# * After switching, now switches back to your original buffer.
#
# * version 0.3: current buffer support
# * If you only specify 1 buffer, the current buffer will be used
#
## Acknowledgements:
# * Sebastien "Flashcode" Helleu, for developing the kick-ass chat/IRC
# client WeeChat
#
## TODO:
# - Check if given buffers exist.
#
## Copyright (c) 2011 Filip H.F. "FiXato" Slagter,
# <FiXato [at] Gmail [dot] com>
# http://google.com/profiles/FiXato
#
# 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:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
SCRIPT_NAME = "buffer_swap"
SCRIPT_AUTHOR = "Filip H.F. 'FiXato' Slagter <fixato [at] gmail [dot] com>"
SCRIPT_VERSION = "0.3"
SCRIPT_LICENSE = "MIT"
SCRIPT_DESC = "Swaps given 2 buffers"
SCRIPT_COMMAND = "swap"
SCRIPT_CLOSE_CB = "close_cb"
import_ok = True
try:
import weechat
except ImportError:
print "This script must be run under WeeChat."
import_ok = False
def close_cb(*kwargs):
return weechat.WEECHAT_RC_OK
def command_main(data, buffer, args):
args = args.split()
curr_buffer = weechat.current_buffer()
curr_buffer_number = weechat.buffer_get_integer(curr_buffer, "number")
if len(args) != 1 and len(args) != 2:
weechat.prnt("", "You need to specify 1 or 2 buffers")
return weechat.WEECHAT_RC_ERROR
if len(args) == 2:
weechat.command("", "/buffer %s" % args[0])
first_buffer = weechat.current_buffer()
first_buffer_number = weechat.buffer_get_integer(first_buffer, "number")
weechat.command("", "/buffer %s" % args[1])
second_buffer = weechat.current_buffer()
second_buffer_number = weechat.buffer_get_integer(second_buffer, "number")
else:
first_buffer = weechat.current_buffer()
first_buffer_number = weechat.buffer_get_integer(first_buffer, "number")
weechat.command("", "/buffer %s" % args[0])
second_buffer = weechat.current_buffer()
second_buffer_number = weechat.buffer_get_integer(second_buffer, "number")
weechat.buffer_set(first_buffer, "number", str(second_buffer_number))
weechat.buffer_set(second_buffer, "number", str(first_buffer_number))
weechat.command("", "/buffer %s" % str(curr_buffer_number))
return weechat.WEECHAT_RC_OK
if __name__ == "__main__" and import_ok:
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
SCRIPT_LICENSE, SCRIPT_DESC, SCRIPT_CLOSE_CB, ""):
# # Set default settings
# for option, default_value in cs_settings.iteritems():
# if not weechat.config_is_set_plugin(option):
# weechat.config_set_plugin(option, default_value)
weechat.hook_command(SCRIPT_COMMAND,
SCRIPT_DESC,
"[buffer] <buffer to swap with>",
"Swaps given buffers: \n"
"the /swap command accepts anything that /buffer would accept for switching buffers\n"
"/swap 3 10\n"
"would swap buffer 3 and 10 of place\n"
"/swap 3\n"
"would swap current buffer with buffer number 10\n"
"/swap 3 #weechat\n"
"would swap buffer 3 and the #weechat buffer of place\n"
"/swap #weechat\n"
"would swap current buffer with the #weechat buffer",
"",
"command_main", "")
This diff is collapsed.
Loading
Loading
@@ -21,6 +21,10 @@
#
#
# History:
# 2018-04-06: Joey Pabalinas <joeypabalinas@gmail.com>
# version 26: fix freezes with too many nicks in one line
# 2018-03-18: nils_2
# version 25: fix unable to run function colorize_config_reload_cb()
# 2017-06-20: lbeziaud <louis.beziaud@ens-rennes.fr>
# version 24: colorize utf8 nicks
# 2017-03-01, arza <arza@arza.us>
Loading
Loading
@@ -81,7 +85,7 @@ w = weechat
 
SCRIPT_NAME = "colorize_nicks"
SCRIPT_AUTHOR = "xt <xt@bash.no>"
SCRIPT_VERSION = "24"
SCRIPT_VERSION = "26"
SCRIPT_LICENSE = "GPL"
SCRIPT_DESC = "Use the weechat nick colors in the chat area"
 
Loading
Loading
@@ -108,7 +112,7 @@ def colorize_config_init():
'''
global colorize_config_file, colorize_config_option
colorize_config_file = weechat.config_new(CONFIG_FILE_NAME,
"colorize_config_reload_cb", "")
"", "")
if colorize_config_file == "":
return
 
Loading
Loading
@@ -142,6 +146,10 @@ def colorize_config_init():
colorize_config_file, section_look, "greedy_matching",
"boolean", "If off, then use lazy matching instead", "", 0,
0, "on", "on", 0, "", "", "", "", "", "")
colorize_config_option["match_limit"] = weechat.config_new_option(
colorize_config_file, section_look, "match_limit",
"integer", "Fall back to lazy matching if greedy matches exceeds this number", "",
20, 1000, "", "", 0, "", "", "", "", "", "")
colorize_config_option["ignore_nicks_in_urls"] = weechat.config_new_option(
colorize_config_file, section_look, "ignore_nicks_in_urls",
"boolean", "If on, don't colorize nicks inside URLs", "", 0,
Loading
Loading
@@ -212,33 +220,50 @@ def colorize_cb(data, modifier, modifier_data, line):
if nick in colored_nicks[buffer]:
nick_color = colored_nicks[buffer][nick]
 
# Let's use greedy matching. Will check against every word in a line.
if w.config_boolean(colorize_config_option['greedy_matching']):
for word in line.split():
if w.config_boolean(colorize_config_option['ignore_nicks_in_urls']) and \
word.startswith(('http://', 'https://')):
continue
if nick in word:
# Is there a nick that contains nick and has a greater lenght?
# If so let's save that nick into var biggest_nick
biggest_nick = ""
for i in colored_nicks[buffer]:
if nick in i and nick != i and len(i) > len(nick):
if i in word:
# If a nick with greater len is found, and that word
# also happens to be in word, then let's save this nick
biggest_nick = i
# If there's a nick with greater len, then let's skip this
# As we will have the chance to colorize when biggest_nick
# iterates being nick.
if len(biggest_nick) > 0 and biggest_nick in word:
pass
elif len(word) < len(biggest_nick) or len(biggest_nick) == 0:
new_word = word.replace(nick, '%s%s%s' % (nick_color, nick, reset))
line = line.replace(word, new_word)
# Let's use lazy matching for nick
else:
try:
# Let's use greedy matching. Will check against every word in a line.
if w.config_boolean(colorize_config_option['greedy_matching']):
cnt = 0
limit = w.config_integer(colorize_config_option['match_limit'])
for word in line.split():
cnt += 1
assert cnt < limit
# if cnt > limit:
# raise RuntimeError('Exceeded colorize_nicks.look.match_limit.');
if w.config_boolean(colorize_config_option['ignore_nicks_in_urls']) and \
word.startswith(('http://', 'https://')):
continue
if nick in word:
# Is there a nick that contains nick and has a greater lenght?
# If so let's save that nick into var biggest_nick
biggest_nick = ""
for i in colored_nicks[buffer]:
cnt += 1
assert cnt < limit
if nick in i and nick != i and len(i) > len(nick):
if i in word:
# If a nick with greater len is found, and that word
# also happens to be in word, then let's save this nick
biggest_nick = i
# If there's a nick with greater len, then let's skip this
# As we will have the chance to colorize when biggest_nick
# iterates being nick.
if len(biggest_nick) > 0 and biggest_nick in word:
pass
elif len(word) < len(biggest_nick) or len(biggest_nick) == 0:
new_word = word.replace(nick, '%s%s%s' % (nick_color, nick, reset))
line = line.replace(word, new_word)
# Switch to lazy matching
else:
raise AssertionError
except AssertionError:
# Let's use lazy matching for nick
nick_color = colored_nicks[buffer][nick]
# The two .? are in case somebody writes "nick:", "nick,", etc
# to address somebody
Loading
Loading
@@ -247,6 +272,7 @@ def colorize_cb(data, modifier, modifier_data, line):
if match is not None:
new_line = line[:match.start(2)] + nick_color+nick+reset + line[match.end(2):]
line = new_line
return line
 
def colorize_input_cb(data, modifier, modifier_data, line):
Loading
Loading
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017 jmui <jmui@jmui.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
#
# A simple script to print a random emoji chosen from a list
#
# Usage: /emojis
#
#
# History:
# 2017-11-17
# 0.1 First version
#
#
SCRIPT_NAME = "emojis"
SCRIPT_AUTHOR = "jmui <jmui@jmui.net>"
SCRIPT_VERSION = "0.1"
SCRIPT_LICENSE = "GPL3"
SCRIPT_DESC = "Send a random emoji to the current buffer"
import_ok = True
try:
import weechat
except ImportError:
print("Script must be used in WeeChat.")
import_ok = False
from random import choice
emojiList = [
'¢‿¢',
'©¿© o',
'ª{•̃̾_•̃̾}ª',
'¬_¬',
'¯\(º_o)/¯',
'¯\(º o)/¯',
'¯\_(⊙︿⊙)_/¯',
'¯\_(ツ)_/¯',
'°ω°',
'°Д°',
'°‿‿°',
'´ ▽ ` )ノ',
'¿ⓧ_ⓧﮌ',
'Ò,ó',
'ó‿ó',
'ô⌐ô',
'ôヮô',
'ŎםŎ',
'ŏﺡó',
'ʕ•̫͡•ʔ',
'ʕ•ᴥ•ʔ',
'ʘ‿ʘ',
'˚•_•˚',
'˚⌇˚',
'˚▱˚',
'Σ ◕ ◡ ◕',
'Σ (゚Д゚;)',
'Σ(゚Д゚;≡;゚д゚)',
'Σ(゚Д゚ )',
'Σ(||゚Д゚)',
'Φ,Φ',
'δﺡό',
'σ_σ',
'д_д',
'ф_ф',
'щ(゚Д゚щ)',
'щ(ಠ益ಠщ)',
'щ(ಥДಥщ)',
'Ծ_Ծ',
'٩๏̯͡๏۶',
'٩๏̯͡๏)۶',
'٩◔̯◔۶',
'٩(×̯×)۶',
'٩(̾●̮̮̃̾•̃̾)۶',
'٩(͡๏̯͡๏)۶',
'٩(͡๏̯ ͡๏)۶',
'٩(ಥ_ಥ)۶',
'٩(•̮̮̃•̃)۶',
'٩(●̮̮̃•̃)۶',
'٩(●̮̮̃●̃)۶',
'٩(。͡•‿•。)۶',
'٩(-̮̮̃•̃)۶',
'٩(-̮̮̃-̃)۶',
'۞_۞',
'۞_۟۞',
'۹ↁﮌↁ',
'۹⌤_⌤۹',
'॓_॔',
'१✌◡✌५',
'१|˚–˚|५',
'ਉ_ਉ',
'ଘ_ଘ',
'இ_இ',
'ఠ_ఠ',
'రృర',
'ಠ¿ಠi',
'ಠ‿ಠ',
'ಠ⌣ಠ',
'ಠ╭╮ಠ',
'ಠ▃ಠ',
'ಠ◡ಠ',
'ಠ益ಠ',
'ಠ益ಠ',
'ಠ︵ಠ凸',
'ಠ , ಥ',
'ಠ.ಠ',
'ಠoಠ',
'ಠ_ృ',
'ಠ_ಠ',
'ಠ_๏',
'ಠ~ಠ',
'ಡ_ಡ',
'ತಎತ',
'ತ_ತ',
'ಥдಥ',
'ಥ‿ಥ',
'ಥ⌣ಥ',
'ಥ◡ಥ',
'ಥ﹏ಥ',
'ಥ_ಥ',
'ಭ_ಭ',
'ರ_ರ',
'ಸ , ໖',
'ಸ_ಸ',
'ക_ക',
'อ้_อ้',
'อ_อ',
'โ๏௰๏ใ ื',
'๏̯͡๏﴿',
'๏̯͡๏',
'๏̯͡๏﴿',
'๏[-ิิ_•ิ]๏',
'๏_๏',
'໖_໖',
'༺‿༻',
'ლ(´ڡ`ლ)',
'ლ(́◉◞౪◟◉‵ლ)',
'ლ(ಠ益ಠლ)',
'ლ(╹◡╹ლ)',
'ლ(◉◞౪◟◉‵ლ)',
'ლ,ᔑ•ﺪ͟͠•ᔐ.ლ',
'ᄽὁȍ ̪ őὀᄿ',
'ᕕ( ᐛ )ᕗ',
'ᕙ(⇀‸↼‶)ᕗ',
'ᕦ(ò_óˇ)ᕤ',
'ᶘ ᵒᴥᵒᶅ',
'‘︿’',
'•▱•',
'•✞_✞•',
'•(⌚_⌚)•',
'•_•)',
'‷̗ↂ凸ↂ‴̖',
'‹•.•›',
'‹› ‹(•¿•)› ‹›',
'‹(ᵒᴥᵒ­­­­­)›',
'‹(•¿•)›',
'ↁ_ↁ',
'⇎_⇎',
'∩(︶▽︶)∩',
'∩( ・ω・)∩',
'≖‿≖',
'≧ヮ≦',
'⊂•⊃_⊂•⊃',
'⊂⌒~⊃。Д。)⊃',
'⊂(◉‿◉)つ',
'⊂(゚Д゚,,⊂⌒`つ',
'⊙ω⊙',
'⊙▂⊙',
'⊙▃⊙',
'⊙△⊙',
'⊙︿⊙',
'⊙﹏⊙',
'⊙0⊙',
'⊛ठ̯⊛',
'⋋ō_ō`',
'━━━ヽ(ヽ(゚ヽ(゚∀ヽ(゚∀゚ヽ(゚∀゚)ノ゚∀゚)ノ∀゚)ノ゚)ノ)ノ━━━',
'┌∩┐(◕_◕)┌∩┐',
'┌( ಠ_ಠ)┘',
'┌( ಥ_ಥ)┘',
'╚(•⌂•)╝',
'╭╮╭╮☜{•̃̾_•̃̾}☞╭╮╭╮',
'╭✬⌢✬╮',
'╮(─▽─)╭',
'╯‵Д′)╯彡┻━┻',
'╰☆╮',
'□_□',
'►_◄',
'◃┆◉◡◉┆▷',
'◉△◉',
'◉︵◉',
'◉_◉',
'○_○',
'●¿●\ ~',
'●_●',
'◔̯◔',
'◔ᴗ◔',
'◔ ⌣ ◔',
'◔_◔',
'◕ω◕',
'◕‿◕',
'◕◡◕',
'◕ ◡ ◕',
'◖♪_♪|◗',
'◖|◔◡◉|◗',
'◘_◘',
'◙‿◙',
'◜㍕◝',
'◪_◪',
'◮_◮',
'☁ ☝ˆ~ˆ☂',
'☆¸☆',
'☉‿⊙',
'☉_☉',
'☐_☐',
'☜(⌒▽⌒)☞',
'☜(゚ヮ゚☜)',
'☜-(ΘLΘ)-☞',
'☝☞✌',
'☮▁▂▃▄☾ ♛ ◡ ♛ ☽▄▃▂▁☮',
'☹_☹',
'☻_☻',
'☼.☼',
'☾˙❀‿❀˙☽',
'♥‿♥',
'♥╣[-_-]╠♥',
'♥╭╮♥',
'♥◡♥',
'✌♫♪˙❤‿❤˙♫♪✌',
'✌.ʕʘ‿ʘʔ.✌',
'✌.|•͡˘‿•͡˘|.✌',
'✖‿✖',
'✖_✖',
'❐‿❑',
'⨀_⨀',
'⨀_Ꙩ',
'⨂_⨂',
'〆(・∀・@)',
'《〠_〠》',
'【•】_【•】',
'〠_〠',
'〴⋋_⋌〵',
'の� �の',
'ニガー? ━━━━━━(゚∀゚)━━━━━━ ニガー?',
'ヽ(´ー` )ノ',
'ヽ(๏∀๏ )ノ',
'ヽ(`Д´)ノ',
'ヽ(o`皿′o)ノ',
'ヽ(`Д´)ノ',
'ㅎ_ㅎ',
'乂◜◬◝乂',
'凸ಠ益ಠ)凸',
'句_句',
'Ꙩ⌵Ꙩ',
'Ꙩ_Ꙩ',
'ꙩ_ꙩ',
'Ꙫ_Ꙫ',
'ꙫ_ꙫ',
'ꙮ_ꙮ',
'흫_흫',
'句_句',
'﴾͡๏̯͡๏﴿',
'¯\(ºдಠ)/¯',
'(·×·)',
'(⌒Д⌒)',
'(╹ェ╹)',
'(♯・∀・)⊃',
'( ´∀`)☆',
'( ´∀`)',
'(゜Д゜)',
'(・∀・)',
'(・A・)',
'(゚∀゚)',
'( ̄へ ̄)',
'( ´☣///_ゝ///☣`)',
'( つ Д `)',
'_☆( ´_⊃`)☆_',
'。◕‿‿◕。',
'。◕ ‿ ◕。',
'!⑈ˆ~ˆ!⑈',
'!(`・ω・。)',
'(¬‿¬)',
'(¬▂¬)',
'(¬_¬)',
'(°ℇ °)',
'(°∀°)',
'(´ω`)',
'(´◉◞౪◟◉)',
'(´ヘ`;)',
'(´・ω・`)',
'(´ー`)',
'(ʘ‿ʘ)',
'(ʘ_ʘ)',
'(˚இ˚)',
'(͡๏̯͡๏)',
'(ΘεΘ;)',
'(ι´Д`)ノ',
'(Ծ‸ Ծ)',
'(॓_॔)',
'(० ्०)',
'(ு८ு_ .:)',
'(ಠ‾ಠ)',
'(ಠ‿ʘ)',
'(ಠ‿ಠ)',
'(ಠ⌣ಠ)',
'(ಠ益ಠ ╬)',
'(ಠ益ಠ)',
'(ಠ_ృ)',
'(ಠ_ಠ)',
'(ಥ﹏ಥ)',
'(ಥ_ಥ)',
'(๏̯͡๏ )',
'(ღ˘⌣˘ღ) ♫・*:.。. .。.:*・',
'(ღ˘⌣˘ღ)',
'(ᵔᴥᵔ)',
'(•ω•)',
'(•‿•)',
'(•⊙ω⊙•)',
'(• ε •)',
'(∩▂∩)',
'(∩︵∩)',
'(∪ ◡ ∪)',
'(≧ω≦)',
'(≧◡≦)',
'(≧ロ≦)',
'(⊙ヮ⊙)',
'(⊙_◎)',
'(⋋▂⋌)',
'(⌐■_■)',
'(─‿‿─)',
'(┛◉Д◉)┛┻━┻',
'(╥_╥)',
'(╬ಠ益ಠ)',
'(╬◣д◢)',
'(╬ ಠ益ಠ)',
'(╯°□°)╯︵ ┻━┻',
'(╯ಊ╰)',
'(╯◕_◕)╯',
'(╯︵╰,)',
'(╯3╰)',
'(╯_╰)',
'(╹◡╹)凸',
'(▰˘◡˘▰)',
'(●´ω`●)',
'(●´∀`●)',
'(◑‿◐)',
'(◑◡◑)',
'(◕‿◕✿)',
'(◕‿◕)',
'(◕‿-)',
'(◕︵◕)',
'(◕ ^ ◕)',
'(◕_◕)',
'(◜௰◝)',
'(◡‿◡✿)',
'(◣_◢)',
'(☞゚∀゚)☞',
'(☞゚ヮ゚)☞',
'(☞゚ ∀゚ )☞',
'(☼◡☼)',
'(☼_☼)',
'(✌゚∀゚)☞',
'(✖╭╮✖)',
'(✪㉨✪)',
'(✿◠‿◠)',
'(✿ ♥‿♥)',
'( ・∀・)',
'( ・ัω・ั)?',
'( ゚∀゚)o彡゜',
'(。・_・。)',
'(つд`)',
'(づ。◕‿‿◕。)づ',
'(ノಠ益ಠ)ノ彡┻━┻',
'(ノ ◑‿◑)ノ',
'(ノ_・。)',
'(・∀・ )',
'(屮゚Д゚)屮',
'(︶ω︶)',
'(︶︹︺)',
'(;一_一)',
'(`・ω・´)”',
'(。◕‿‿◕。)',
'(。◕‿◕。)',
'(。◕ ‿ ◕。)',
'(。♥‿♥。)',
'(。・ω..・)っ',
'(・ェ-)',
'(ノ◕ヮ◕)ノ*:・゚✧',
'(゚Д゚)',
'(゚Д゚)y─┛~~',
'(゚∀゚)',
'(゚ヮ゚)',
'( ̄□ ̄)',
'( ̄。 ̄)',
'( ̄ー ̄)',
'( ̄(エ) ̄)',
'( °٢° )',
'( ´_ゝ`)',
'( ͡° ͜ʖ ͡°)',
'( ͡~ ͜ʖ ͡°)',
'( ಠ◡ಠ )',
'( •_•)>⌐■-■',
'( ゚,_ゝ゚)',
'( ・ิз・ิ)',
'( ゚д゚)、',
'( ^▽^)σ)~O~)',
'((((゜д゜;))))',
'(*´д`*)',
'(*..Д`)',
'(*..д`*)',
'(*~▽~)',
'(-’๏_๏’-)',
'(-_- )ノ',
'(/◔ ◡ ◔)/',
'(///_ಥ)',
'(;´Д`)',
'(=ω=;)',
'(=゜ω゜)',
'(>\'o\')> ♥ <(\'o\'<)',
'(n˘v˘•)¬',
'(o´ω`o)',
'(V)(°,,°)(V)',
'(\/) (°,,°) (\/)',
'(^▽^)',
'(`・ω・´)',
'(~ ̄▽ ̄)~',
'\= (゚д゚)ウ',
'@_@',
'd(*⌒▽⌒*)b',
'o(≧∀≦)o',
'o(≧o≦)o',
'q(❂‿❂)p',
'y=ー( ゚д゚)・∵.',
'\˚ㄥ˚\ ',
'\ᇂ_ᇂ\ ',
'\(ಠ ὡ ಠ )/',
'\(◕ ◡ ◕\)',
'^̮^',
'^ㅂ^',
'_(͡๏̯͡๏)_',
'{´◕ ◡ ◕`}',
'\{ಠ_ಠ\}__,,|,',
'{◕ ◡ ◕}',
]
def print_face(data, buf, args):
weechat.command(buf, choice(emojiList))
return weechat.WEECHAT_RC_OK
if __name__ == "__main__" and import_ok:
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
weechat.hook_command(SCRIPT_NAME, SCRIPT_DESC, "", "", "",
"print_face", "")
Loading
Loading
@@ -69,6 +69,10 @@
#
# History:
#
# 2018-04-10, Sébastien Helleu <flashcode@flashtux.org>
# version 0.8.1: fix infolist_time for WeeChat >= 2.2 (WeeChat returns a long
# integer instead of a string)
#
# 2017-09-20, mickael9
# version 0.8:
# * use weechat 1.5+ api for background processing (old method was unsafe and buggy)
Loading
Loading
@@ -222,7 +226,7 @@ except ImportError:
 
SCRIPT_NAME = "grep"
SCRIPT_AUTHOR = "Elián Hanisch <lambdae2@gmail.com>"
SCRIPT_VERSION = "0.8"
SCRIPT_VERSION = "0.8.1"
SCRIPT_LICENSE = "GPL3"
SCRIPT_DESC = "Search in buffers and logs"
SCRIPT_COMMAND = "grep"
Loading
Loading
@@ -844,6 +848,10 @@ def grep_buffer(buffer, head, tail, after_context, before_context, count, regexp
prefix = string_remove_color(infolist_string(infolist, 'prefix'), '')
message = string_remove_color(infolist_string(infolist, 'message'), '')
date = infolist_time(infolist, 'date')
# since WeeChat 2.2, infolist_time returns a long integer
# instead of a string
if not isinstance(date, str):
date = time.strftime('%F %T', time.localtime(int(date)))
return '%s\t%s\t%s' %(date, prefix, message)
return function
get_line = make_get_line_funcion()
Loading
Loading
# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2012 Sebastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2008-2018 Sébastien Helleu <flashcode@flashtux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Loading
Loading
@@ -18,58 +19,72 @@
# Display infolist in a buffer.
#
# History:
#
# 2018-04-10, Sébastien Helleu <flashcode@flashtux.org>:
# version 0.7: fix infolist_time for WeeChat >= 2.2 (WeeChat returns a long
# integer instead of a string), fix PEP8 errors
# 2017-10-22, nils_2 <freenode.#weechat>:
# version 0.6: add string_eval_expression()
# 2012-10-02, nils_2 <freenode.#weechat>:
# version 0.5: switch to infolist buffer (if exists) when command /infolist
# is called with arguments, add some examples to help page
# 2012-01-03, Sebastien Helleu <flashcode@flashtux.org>:
# 2012-01-03, Sébastien Helleu <flashcode@flashtux.org>:
# version 0.4: make script compatible with Python 3.x
# 2010-01-23, m4v <lambdae2@gmail.com>:
# version 0.3: user can give a pointer as argument
# 2010-01-18, Sebastien Helleu <flashcode@flashtux.org>:
# 2010-01-18, Sébastien Helleu <flashcode@flashtux.org>:
# version 0.2: use tag "no_filter" for lines displayed, fix display bug
# when infolist is empty
# 2009-11-30, Sebastien Helleu <flashcode@flashtux.org>:
# 2009-11-30, Sébastien Helleu <flashcode@flashtux.org>:
# version 0.1: first version
# 2008-12-12, Sebastien Helleu <flashcode@flashtux.org>:
# 2008-12-12, Sébastien Helleu <flashcode@flashtux.org>:
# script creation
 
SCRIPT_NAME = "infolist"
SCRIPT_AUTHOR = "Sebastien Helleu <flashcode@flashtux.org>"
SCRIPT_VERSION = "0.6"
SCRIPT_NAME = "infolist"
SCRIPT_AUTHOR = "Sébastien Helleu <flashcode@flashtux.org>"
SCRIPT_VERSION = "0.7"
SCRIPT_LICENSE = "GPL3"
SCRIPT_DESC = "Display infolist in a buffer"
SCRIPT_DESC = "Display infolist in a buffer"
 
import_ok = True
try:
import weechat
except:
except ImportError:
print("This script must be run under WeeChat.")
print("Get WeeChat now at: http://www.weechat.org/")
import_ok = False
 
try:
import time
except ImportError as message:
print('Missing package(s) for %s: %s' % (SCRIPT_NAME, message))
import_ok = False
infolist_buffer = ""
infolist_var_type = { "i": "int",
"s": "str",
"p": "ptr",
"t": "tim",
"b": "buf",
}
infolist_var_type = {
"i": "int",
"s": "str",
"p": "ptr",
"t": "tim",
"b": "buf",
}
 
 
def infolist_buffer_set_title(buffer):
# get list of infolists available
list = ""
list_infolists = ""
infolist = weechat.infolist_get("hook", "", "infolist")
while weechat.infolist_next(infolist):
list += " %s" % weechat.infolist_string(infolist, "infolist_name")
list_infolists += " %s" % weechat.infolist_string(infolist,
"infolist_name")
weechat.infolist_free(infolist)
 
# set buffer title
weechat.buffer_set(buffer, "title",
"%s %s | Infolists:%s" % (SCRIPT_NAME, SCRIPT_VERSION, list))
"%s %s | Infolists:%s" % (
SCRIPT_NAME, SCRIPT_VERSION, list_infolists))
 
def infolist_display(buffer, args):
global infolist_var_type
Loading
Loading
@@ -93,9 +108,10 @@ def infolist_display(buffer, args):
 
item_count = 0
weechat.buffer_clear(buffer)
weechat.prnt_date_tags(buffer, 0, "no_filter",
"Infolist '%s', with pointer '%s' and arguments '%s':" % (items[0],
infolist_pointer, infolist_args))
weechat.prnt_date_tags(
buffer, 0, "no_filter",
"Infolist '%s', with pointer '%s' and arguments '%s':" % (
items[0], infolist_pointer, infolist_args))
weechat.prnt(buffer, "")
count = 0
while weechat.infolist_next(infolist):
Loading
Loading
@@ -121,15 +137,22 @@ def infolist_display(buffer, args):
value = weechat.infolist_pointer(infolist, name)
elif type == "t":
value = weechat.infolist_time(infolist, name)
# since WeeChat 2.2, infolist_time returns a long integer
# instead of a string
if not isinstance(value, str):
str_date = time.strftime('%F %T',
time.localtime(int(value)))
value = '%d (%s)' % (value, str_date)
name_end = "." * (30 - len(name))
weechat.prnt_date_tags(buffer, 0, "no_filter",
"%s%s%s: %s%s%s %s%s%s%s%s%s" %
(prefix, name, name_end,
weechat.color("brown"), infolist_var_type[type],
weechat.color("chat"),
weechat.color("chat"), quote,
weechat.color("cyan"), value,
weechat.color("chat"), quote))
weechat.prnt_date_tags(
buffer, 0, "no_filter",
"%s%s%s: %s%s%s %s%s%s%s%s%s" %
(prefix, name, name_end,
weechat.color("brown"), infolist_var_type[type],
weechat.color("chat"),
weechat.color("chat"), quote,
weechat.color("cyan"), value,
weechat.color("chat"), quote))
prefix = ""
count += 1
if count == 0:
Loading
Loading
@@ -137,6 +160,7 @@ def infolist_display(buffer, args):
weechat.infolist_free(infolist)
return weechat.WEECHAT_RC_OK
 
def infolist_buffer_input_cb(data, buffer, input_data):
if input_data == "q" or input_data == "Q":
weechat.buffer_close(buffer)
Loading
Loading
@@ -144,12 +168,14 @@ def infolist_buffer_input_cb(data, buffer, input_data):
infolist_display(buffer, input_data)
return weechat.WEECHAT_RC_OK
 
def infolist_buffer_close_cb(data, buffer):
global infolist_buffer
 
infolist_buffer = ""
return weechat.WEECHAT_RC_OK
 
def infolist_buffer_new():
global infolist_buffer
 
Loading
Loading
@@ -164,6 +190,7 @@ def infolist_buffer_new():
weechat.buffer_set(infolist_buffer, "time_for_each_line", "0")
weechat.buffer_set(infolist_buffer, "display", "1")
 
def infolist_cmd(data, buffer, args):
global infolist_buffer
 
Loading
Loading
@@ -173,32 +200,36 @@ def infolist_cmd(data, buffer, args):
infolist_buffer_new()
if infolist_buffer != "" and args != "":
infolist_display(infolist_buffer, args)
weechat.buffer_set(infolist_buffer, "display", "1");
weechat.buffer_set(infolist_buffer, "display", "1")
 
return weechat.WEECHAT_RC_OK
 
def string_eval_expression(string):
return weechat.string_eval_expression(string,{},{},{})
return weechat.string_eval_expression(string, {}, {}, {})
 
if __name__ == "__main__" and import_ok:
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
SCRIPT_DESC, "", ""):
weechat.hook_command("infolist", "Display infolist in a buffer",
"[infolist [pointer] [arguments]]",
" infolist: name of infolist\n"
" pointer: optional pointer for infolist (\"\" for none)\n"
"arguments: optional arguments for infolist\n\n"
"Command without argument will open buffer used "
"to display infolists.\n\n"
"On infolist buffer, you can enter name of an "
"infolist, with optional arguments.\n"
"Enter 'q' to close infolist buffer.\n\n"
"Examples:\n"
" Show information about nick \"FlashCode\" in channel \"#weechat\" on server \"freenode\":\n"
" /infolist irc_nick freenode,#weechat,FlashCode\n"
" Show nicklist from a specific buffer:\n"
" /infolist nicklist <buffer pointer>\n"
" Show current buffer:\n"
" /infolist buffer ${buffer}"
"",
"%(infolists)", "infolist_cmd", "")
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
weechat.hook_command(
"infolist", "Display infolist in a buffer",
"[infolist [pointer] [arguments]]",
" infolist: name of infolist\n"
" pointer: optional pointer for infolist (\"\" for none)\n"
"arguments: optional arguments for infolist\n\n"
"Command without argument will open buffer used "
"to display infolists.\n\n"
"On infolist buffer, you can enter name of an "
"infolist, with optional arguments.\n"
"Enter 'q' to close infolist buffer.\n\n"
"Examples:\n"
" Show information about nick \"FlashCode\" in channel "
"\"#weechat\" on server \"freenode\":\n"
" /infolist irc_nick freenode,#weechat,FlashCode\n"
" Show nicklist from a specific buffer:\n"
" /infolist nicklist <buffer pointer>\n"
" Show current buffer:\n"
" /infolist buffer ${buffer}"
"",
"%(infolists)", "infolist_cmd", "")
Loading
Loading
@@ -10,7 +10,25 @@
# based on:
# growl.py
# Copyright (c) 2011 Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Changelog:
# Ver: 0.4 by Antonin Skala tony762@gmx.com 3.2018
#
# Changed dcc regex to match new notify appears (weechat notify now contain IP)
# Added dcc send offer and dcc send start notify
# Setting for notify is divided to off (don't send), on (always send),
# away (send only when away).
# Changed default settings to match new scheme
# DCC get request show name with ip, network and size of file.
#
# Help:
# Install and configure msmtp first (msmtp.sourceforge.net/)
# List and Change plugin settings by /set plugins.var.python.mnotify.*
# Change language to english -otherwise this will not work
# /set env LANG en_US.UTF-8
# /save
# /upgrade
#
 
# -----------------------------------------------------------------------------
# Imports
Loading
Loading
@@ -25,7 +43,7 @@ import weechat
 
SCRIPT_NAME = 'mnotify'
SCRIPT_AUTHOR = 'maker'
SCRIPT_VERSION = '0.3'
SCRIPT_VERSION = '0.4'
SCRIPT_LICENSE = 'Beerware License'
SCRIPT_DESC = 'Sends mail notifications upon events.'
 
Loading
Loading
@@ -34,21 +52,19 @@ SCRIPT_DESC = 'Sends mail notifications upon events.'
# -----------------------------------------------------------------------------
SETTINGS = {
'show_public_message': 'off',
'show_private_message': 'on',
'show_private_message': 'away',
'show_public_action_message': 'off',
'show_private_action_message': 'on',
'show_private_action_message': 'away',
'show_notice_message': 'off',
'show_invite_message': 'on',
'show_highlighted_message': 'on',
'show_server': 'on',
'show_channel_topic': 'on',
'show_invite_message': 'away',
'show_highlighted_message': 'off',
'show_server': 'away',
'show_channel_topic': 'off',
'show_dcc': 'on',
'show_upgrade_ended': 'on',
'sticky': 'off',
'sticky_away': 'on',
'sendmail': 'msmtp',
'email_to': '',
'email_from': 'irc <irc@localhost>'
'show_upgrade_ended': 'off',
'sendmail': '/usr/bin/msmtp',
'email_to': 'somebody@somwhere.xx',
'email_from': 'irc@somwhere.xx'
}
 
 
Loading
Loading
@@ -70,23 +86,27 @@ UNTAGGED_MESSAGES = {
'away status':
re.compile(r'^You ((\w+).){2,3}marked as being away', re.UNICODE),
'dcc chat request':
re.compile(r'^xfer: incoming chat request from (\w+)', re.UNICODE),
re.compile(r'^xfer: incoming chat request from ([^\s]+) ', re.UNICODE),
'dcc chat closed':
re.compile(r'^xfer: chat closed with (\w+)', re.UNICODE),
re.compile(r'^xfer: chat closed with ([^\s]+) \(', re.UNICODE),
'dcc get request':
re.compile(
r'^xfer: incoming file from (\w+) [^:]+: ((?:,\w|[^,])+),',
r'^xfer: incoming file from (^\s|.+), name: ((?:,\w|[^,])+), (\d+) bytes',
re.UNICODE),
'dcc get completed':
re.compile(r'^xfer: file ([^\s]+) received from \w+: OK', re.UNICODE),
re.compile(r'^xfer: file ((?:,\w|[^,])+) received from ([^\s]+) ((?:,\w|[^,]+)): OK$', re.UNICODE),
'dcc get failed':
re.compile(
r'^xfer: file ([^\s]+) received from \w+: FAILED',
r'^xfer: file ((?:,\w|[^,])+) received from ([^\s]+) ((?:,\w|[^,]+)): FAILED$',
re.UNICODE),
'dcc send offer':
re.compile(r'^xfer: offering file to ([^\s]+) ((?:,\w|[^,])+), name: ((?:,\w|[^,])+) \(local', re.UNICODE),
'dcc send start':
re.compile(r'^xfer: sending file to ([^\s]+) ((?:,\w|.)+), name: ((?:,\w|[^,])+) \(local', re.UNICODE),
'dcc send completed':
re.compile(r'^xfer: file ([^\s]+) sent to \w+: OK', re.UNICODE),
re.compile(r'^xfer: file ((?:,\w|[^,])+) sent to ([^\s]+) ((?:,\w|[^,]+)): OK$', re.UNICODE),
'dcc send failed':
re.compile(r'^xfer: file ([^\s]+) sent to \w+: FAILED', re.UNICODE),
re.compile(r'^xfer: file ((?:,\w|[^,])+) sent to ([^\s]+) ((?:,\w|[^,]+)): FAILED$', re.UNICODE),
}
 
 
Loading
Loading
@@ -102,6 +122,8 @@ DISPATCH_TABLE = {
'dcc get request': 'notify_dcc_get_request',
'dcc get completed': 'notify_dcc_get_completed',
'dcc get failed': 'notify_dcc_get_failed',
'dcc send offer': 'notify_dcc_send_offer',
'dcc send start': 'notify_dcc_send_start',
'dcc send completed': 'notify_dcc_send_completed',
'dcc send failed': 'notify_dcc_send_failed',
}
Loading
Loading
@@ -118,7 +140,9 @@ STATE = {
# -----------------------------------------------------------------------------
def cb_irc_server_connected(data, signal, signal_data):
'''Notify when connected to IRC server.'''
if weechat.config_get_plugin('show_server') == 'on':
if (weechat.config_get_plugin('show_server') == 'on'
or (weechat.config_get_plugin('show_server') == "away"
and STATE['is_away'])):
a_notify(
'Server',
'Server Connected',
Loading
Loading
@@ -128,7 +152,9 @@ def cb_irc_server_connected(data, signal, signal_data):
 
def cb_irc_server_disconnected(data, signal, signal_data):
'''Notify when disconnected to IRC server.'''
if weechat.config_get_plugin('show_server') == 'on':
if (weechat.config_get_plugin('show_server') == 'on'
or (weechat.config_get_plugin('show_server') == "away"
and STATE['is_away'])):
a_notify(
'Server',
'Server Disconnected',
Loading
Loading
@@ -138,7 +164,9 @@ def cb_irc_server_disconnected(data, signal, signal_data):
 
def cb_notify_upgrade_ended(data, signal, signal_data):
'''Notify on end of WeeChat upgrade.'''
if weechat.config_get_plugin('show_upgrade_ended') == 'on':
if (weechat.config_get_plugin('show_upgrade_ended') == 'on'
or (weechat.config_get_plugin('show_upgrade_ended') == "away"
and STATE['is_away'])):
a_notify(
'WeeChat',
'WeeChat Upgraded',
Loading
Loading
@@ -148,7 +176,9 @@ def cb_notify_upgrade_ended(data, signal, signal_data):
 
def notify_highlighted_message(buffername, prefix, message):
'''Notify on highlighted message.'''
if weechat.config_get_plugin("show_highlighted_message") == "on":
if (weechat.config_get_plugin("show_highlighted_message") == "on"
or (weechat.config_get_plugin("show_highlighted_message") == "away"
and STATE['is_away'])):
a_notify(
'Highlight',
'Highlighted on {0} by {1}'.format(buffername, prefix),
Loading
Loading
@@ -169,7 +199,9 @@ def notify_public_message_or_action(buffername, prefix, message, highlighted):
else:
if highlighted:
notify_highlighted_message(buffername, prefix, message)
elif weechat.config_get_plugin("show_public_message") == "on":
elif (weechat.config_get_plugin("show_public_message") == "on"
or (weechat.config_get_plugin("show_public_message") == "away"
and STATE['is_away'])):
a_notify(
'Public',
'Public Message on {0}'.format(buffername),
Loading
Loading
@@ -195,7 +227,9 @@ def notify_private_message_or_action(buffername, prefix, message, highlighted):
else:
if highlighted:
notify_highlighted_message(buffername, prefix, message)
elif weechat.config_get_plugin("show_private_message") == "on":
elif (weechat.config_get_plugin("show_private_message") == "on"
or (weechat.config_get_plugin("show_private_message") == "away"
and STATE['is_away'])):
a_notify(
'Private',
'Private Message',
Loading
Loading
@@ -206,7 +240,9 @@ def notify_public_action_message(buffername, prefix, message, highlighted):
'''Notify on public action message.'''
if highlighted:
notify_highlighted_message(buffername, prefix, message)
elif weechat.config_get_plugin("show_public_action_message") == "on":
elif (weechat.config_get_plugin("show_public_action_message") == "on"
or (weechat.config_get_plugin("show_public_action_message") == "away"
and STATE['is_away'])):
a_notify(
'Action',
'Public Action Message on {0}'.format(buffername),
Loading
Loading
@@ -218,13 +254,16 @@ def notify_private_action_message(buffername, prefix, message, highlighted):
'''Notify on private action message.'''
if highlighted:
notify_highlighted_message(buffername, prefix, message)
elif weechat.config_get_plugin("show_private_action_message") == "on":
elif (weechat.config_get_plugin("show_private_action_message") == "on"
or (weechat.config_get_plugin("show_private_action_message") == "away"
and STATE['is_away'])):
a_notify(
'Action',
'Private Action Message',
'{0}: {1}'.format(prefix, message),
)
 
def notify_notice_message(buffername, prefix, message, highlighted):
'''Notify on notice message.'''
regex = re.compile(r'^([^\s]*) [^:]*: (.+)$', re.UNICODE)
Loading
Loading
@@ -234,7 +273,9 @@ def notify_notice_message(buffername, prefix, message, highlighted):
message = match.group(2)
if highlighted:
notify_highlighted_message(buffername, prefix, message)
elif weechat.config_get_plugin("show_notice_message") == "on":
elif (weechat.config_get_plugin("show_notice_message") == "on"
or (weechat.config_get_plugin("show_notice_message") == "away"
and STATE['is_away'])):
a_notify(
'Notice',
'Notice Message',
Loading
Loading
@@ -243,7 +284,9 @@ def notify_notice_message(buffername, prefix, message, highlighted):
 
def notify_invite_message(buffername, prefix, message, highlighted):
'''Notify on channel invitation message.'''
if weechat.config_get_plugin("show_invite_message") == "on":
if (weechat.config_get_plugin("show_invite_message") == "on"
or (weechat.config_get_plugin("show_invite_message") == "away"
and STATE['is_away'])):
regex = re.compile(
r'^You have been invited to ([^\s]+) by ([^\s]+)$', re.UNICODE)
match = regex.match(message)
Loading
Loading
@@ -258,10 +301,12 @@ def notify_invite_message(buffername, prefix, message, highlighted):
 
def notify_channel_topic(buffername, prefix, message, highlighted):
'''Notify on channel topic change.'''
if weechat.config_get_plugin("show_channel_topic") == "on":
if (weechat.config_get_plugin("show_channel_topic") == "on"
or (weechat.config_get_plugin("show_channel_topic") == "away"
and STATE['is_away'])):
regex = re.compile(
r'^\w+ has (?:changed|unset) topic for ([^\s]+)' +
'(?:(?: from "(?:.+)")? to "(.+)")?',
r'(?:(?: from "(?:.+)")? to "(.+)")?',
re.UNICODE)
match = regex.match(message)
if match:
Loading
Loading
@@ -275,7 +320,9 @@ def notify_channel_topic(buffername, prefix, message, highlighted):
 
def notify_dcc_chat_request(match):
'''Notify on DCC chat request.'''
if weechat.config_get_plugin("show_dcc") == "on":
if (weechat.config_get_plugin("show_dcc") == "on"
or (weechat.config_get_plugin("show_dcc") == "away"
and STATE['is_away'])):
nick = match.group(1)
a_notify(
'DCC',
Loading
Loading
@@ -285,7 +332,9 @@ def notify_dcc_chat_request(match):
 
def notify_dcc_chat_closed(match):
'''Notify on DCC chat termination.'''
if weechat.config_get_plugin("show_dcc") == "on":
if (weechat.config_get_plugin("show_dcc") == "on"
or (weechat.config_get_plugin("show_dcc") == "away"
and STATE['is_away'])):
nick = match.group(1)
a_notify(
'DCC',
Loading
Loading
@@ -295,41 +344,93 @@ def notify_dcc_chat_closed(match):
 
def notify_dcc_get_request(match):
'Notify on DCC get request.'
if weechat.config_get_plugin("show_dcc") == "on":
if (weechat.config_get_plugin("show_dcc") == "on"
or (weechat.config_get_plugin("show_dcc") == "away"
and STATE['is_away'])):
nick = match.group(1)
file_name = match.group(2)
file_size = int(match.group(3))
a_notify(
'DCC',
'File Transfer Request',
'{0} wants to send you {1}.'.format(nick, file_name))
'{0} wants to send you {1} and size is {2}.'.format(nick, file_name, humanbytes(file_size)))
 
 
def notify_dcc_get_completed(match):
'Notify on DCC get completion.'
if weechat.config_get_plugin("show_dcc") == "on":
if (weechat.config_get_plugin("show_dcc") == "on"
or (weechat.config_get_plugin("show_dcc") == "away"
and STATE['is_away'])):
nick = match.group(2)
file_name = match.group(1)
a_notify('DCC', 'Download Complete', file_name)
a_notify(
'DCC',
'Download Complete',
'Downloading {1} from {0} completed.'.format(nick, file_name))
 
 
def notify_dcc_get_failed(match):
'Notify on DCC get failure.'
if weechat.config_get_plugin("show_dcc") == "on":
if (weechat.config_get_plugin("show_dcc") == "on"
or (weechat.config_get_plugin("show_dcc") == "away"
and STATE['is_away'])):
file_name = match.group(1)
a_notify('DCC', 'Download Failed', file_name)
a_notify(
'DCC',
'Download Failed',
'Downloading {1} from {0} failed.'.format(nick, file_name))
def notify_dcc_send_offer(match):
'Notify on DCC send offer.'
if (weechat.config_get_plugin("show_dcc") == "on"
or (weechat.config_get_plugin("show_dcc") == "away"
and STATE['is_away'])):
nick = match.group(1)
file_name = match.group(3)
a_notify(
'DCC',
'Offering File Upload',
'Offering {1} to {0}.'.format(nick, file_name))
def notify_dcc_send_start(match):
'Notify on DCC send start.'
if (weechat.config_get_plugin("show_dcc") == "on"
or (weechat.config_get_plugin("show_dcc") == "away"
and STATE['is_away'])):
nick = match.group(1)
file_name = match.group(3)
a_notify(
'DCC',
'Start File Upload',
'Uploading {1} to {0}.'.format(nick, file_name))
 
 
def notify_dcc_send_completed(match):
'Notify on DCC send completion.'
if weechat.config_get_plugin("show_dcc") == "on":
if (weechat.config_get_plugin("show_dcc") == "on"
or (weechat.config_get_plugin("show_dcc") == "away"
and STATE['is_away'])):
nick = match.group(2)
file_name = match.group(1)
a_notify('DCC', 'Upload Complete', file_name)
a_notify(
'DCC',
'Upload Complete',
'Upload {1} to {0} completed.'.format(nick, file_name))
 
 
def notify_dcc_send_failed(match):
'Notify on DCC send failure.'
if weechat.config_get_plugin("show_dcc") == "on":
if (weechat.config_get_plugin("show_dcc") == "on"
or (weechat.config_get_plugin("show_dcc") == "away"
and STATE['is_away'])):
nick = match.group(2)
file_name = match.group(1)
a_notify('DCC', 'Upload Failed', file_name)
a_notify(
'DCC',
'Upload Failed',
'Upload {1} to {0} failed.'.format(nick, file_name))
 
 
# -----------------------------------------------------------------------------
Loading
Loading
@@ -384,12 +485,25 @@ def cb_process_message(
return weechat.WEECHAT_RC_OK
 
 
def a_notify(notification, subject, message):
if STATE['is_away'] and weechat.config_get_plugin('sticky_away') == 'off':
return
if not STATE['is_away'] and weechat.config_get_plugin('sticky') == 'off':
return
def humanbytes(B):
B = float(B)
KB = float(1024)
MB = float(KB ** 2) # 1,048,576
GB = float(KB ** 3) # 1,073,741,824
TB = float(KB ** 4) # 1,099,511,627,776
if B < KB:
return '{0} {1}'.format(B,'Bytes' if 0 == B > 1 else 'Byte')
elif KB <= B < MB:
return '{0:.2f} KB'.format(B/KB)
elif MB <= B < GB:
return '{0:.2f} MB'.format(B/MB)
elif GB <= B < TB:
return '{0:.2f} GB'.format(B/GB)
elif TB <= B:
return '{0:.2f} TB'.format(B/TB)
 
def a_notify(notification, subject, message):
msg = MIMEText(message)
msg['From'] = weechat.config_get_plugin('email_from')
msg['To'] = weechat.config_get_plugin('email_to')
Loading
Loading
Loading
Loading
@@ -121,7 +121,8 @@ class PythonVersion3(object):
"""Convert a Unicode to a utf-8 encoded string."""
return strng
 
if sys.version_info.major >= 3:
# We cannot use version_info.major as this is only supported on python >= 2.7
if sys.version_info[0] >= 3:
PYVER = PythonVersion3(sys.version_info.minor)
else:
PYVER = PythonVersion2()
Loading
Loading
@@ -163,7 +164,7 @@ This script supports only OTR protocol version 2.
 
SCRIPT_AUTHOR = 'Matthew M. Boedicker'
SCRIPT_LICENCE = 'GPL3'
SCRIPT_VERSION = '1.9.1'
SCRIPT_VERSION = '1.9.2'
 
OTR_DIR_NAME = 'otr'
 
Loading
Loading
@@ -268,7 +269,7 @@ def print_buffer(buf, message, level='info'):
using color according to level."""
prnt(buf, '{prefix}\t{msg}'.format(
prefix=get_prefix(),
msg=colorize(message, 'buffer.{}'.format(level))))
msg=colorize(message, 'buffer.{0}'.format(level))))
 
def get_prefix():
"""Returns configured message prefix."""
Loading
Loading
@@ -394,7 +395,7 @@ def config_prefix(option):
def config_color(option):
"""Get the color of a color config option."""
return weechat.color(weechat.config_color(config_get_prefixed(
'color.{}'.format(option))))
'color.{0}'.format(option))))
 
def config_string(option):
"""Get the string value of a config option with utf-8 decode."""
Loading
Loading
@@ -468,7 +469,7 @@ def format_default_policies():
buf.write(' {policy} ({desc}) : {value}\n'.format(
policy=policy,
desc=desc,
value=config_string('policy.default.{}'.format(policy))))
value=config_string('policy.default.{0}'.format(policy))))
 
buf.write('Change default policies with: /otr policy default NAME on|off')
 
Loading
Loading
@@ -533,7 +534,7 @@ def show_peer_fingerprints(grep=None):
 
def private_key_file_path(account_name):
"""Return the private key file path for an account."""
return os.path.join(OTR_DIR, '{}.key3'.format(account_name))
return os.path.join(OTR_DIR, '{0}.key3'.format(account_name))
 
def read_private_key(key_file_path):
"""Return the private key in a private key file."""
Loading
Loading
@@ -631,7 +632,7 @@ class IrcContext(potr.context.Context):
 
if option == '':
option = config_get_prefixed(
'policy.default.{}'.format(key_lower))
'policy.default.{0}'.format(key_lower))
 
result = bool(weechat.config_boolean(option))
 
Loading
Loading
@@ -646,7 +647,7 @@ class IrcContext(potr.context.Context):
else:
msg = PYVER.to_unicode(msg)
 
debug(('inject', msg, 'len {}'.format(len(msg)), appdata))
debug(('inject', msg, 'len {0}'.format(len(msg)), appdata))
 
privmsg(self.peer_server, self.peer_nick, msg)
 
Loading
Loading
@@ -684,7 +685,7 @@ class IrcContext(potr.context.Context):
 
if trust is None:
fpr = str(self.getCurrentKey())
self.print_buffer('New fingerprint: {}'.format(fpr), 'warning')
self.print_buffer('New fingerprint: {0}'.format(fpr), 'warning')
self.setCurrentTrust('')
 
if bool(trust):
Loading
Loading
@@ -711,7 +712,7 @@ class IrcContext(potr.context.Context):
"""Return the max message size for this context."""
# remove 'PRIVMSG <nick> :' from max message size
result = self.user.maxMessageSize - 10 - len(self.peer_nick)
debug('max message size {}'.format(result))
debug('max message size {0}'.format(result))
 
return result
 
Loading
Loading
@@ -941,16 +942,16 @@ Note: You can safely omit specifying the peer and server when
 
if (previous_log_level >= 0) and (previous_log_level < 10):
self.print_buffer(
'Restoring buffer logging value to: {}'.format(
'Restoring buffer logging value to: {0}'.format(
previous_log_level), 'warning')
weechat.command(buf, '/mute logger set {}'.format(
weechat.command(buf, '/mute logger set {0}'.format(
previous_log_level))
 
if previous_log_level == -1:
logger_option_name = self.get_logger_option_name()
self.print_buffer(
'Restoring buffer logging value to default', 'warning')
weechat.command(buf, '/mute unset {}'.format(
weechat.command(buf, '/mute unset {0}'.format(
logger_option_name))
 
del self.previous_log_level
Loading
Loading
@@ -1000,7 +1001,7 @@ Note: You can safely omit specifying the peer and server when
 
def __repr__(self):
return PYVER.to_str((
'<{} {:x} peer_nick={c.peer_nick} peer_server={c.peer_server}>'
'<{0} {1:x} peer_nick={c.peer_nick} peer_server={c.peer_server}>'
).format(self.__class__.__name__, id(self), c=self))
 
class IrcOtrAccount(potr.context.Account):
Loading
Loading
@@ -1022,7 +1023,7 @@ class IrcOtrAccount(potr.context.Account):
self.defaultQuery = self.defaultQuery.replace("\n", ' ')
 
self.key_file_path = private_key_file_path(name)
self.fpr_file_path = os.path.join(OTR_DIR, '{}.fpr'.format(name))
self.fpr_file_path = os.path.join(OTR_DIR, '{0}.fpr'.format(name))
 
self.load_trusts()
 
Loading
Loading
@@ -1124,7 +1125,7 @@ class IrcHTMLParser(PYVER.html_parser.HTMLParser):
if self.result[self.linkstart:] == self.linktarget:
self.result += ']'
else:
self.result += ']({})'.format(self.linktarget)
self.result += ']({0})'.format(self.linktarget)
self.linktarget = ''
 
def handle_data(self, data):
Loading
Loading
@@ -1137,7 +1138,7 @@ class IrcHTMLParser(PYVER.html_parser.HTMLParser):
self.result += PYVER.unichr(
PYVER.html_entities.name2codepoint[name])
except KeyError:
self.result += '&{};'.format(name)
self.result += '&{0};'.format(name)
 
def handle_charref(self, name):
"""Called for character references, such as &#39;"""
Loading
Loading
@@ -1147,7 +1148,7 @@ class IrcHTMLParser(PYVER.html_parser.HTMLParser):
else:
self.result += PYVER.unichr(int(name))
except ValueError:
self.result += '&#{};'.format(name)
self.result += '&#{0};'.format(name)
 
class TableFormatter(object):
"""Format lists of string into aligned tables."""
Loading
Loading
@@ -1209,7 +1210,7 @@ def message_in_cb(data, modifier, modifier_data, string):
 
context.handle_tlvs(tlvs)
except potr.context.ErrorReceived as err:
context.print_buffer('Received OTR error: {}'.format(
context.print_buffer('Received OTR error: {0}'.format(
PYVER.to_unicode(err.args[0])), 'error')
except potr.context.NotEncryptedError:
context.print_buffer(
Loading
Loading
@@ -1385,9 +1386,9 @@ def command_cb(data, buf, args):
if context.is_encrypted():
context.print_buffer(
'This conversation is encrypted.', 'success')
context.print_buffer("Your fingerprint is: {}".format(
context.print_buffer("Your fingerprint is: {0}".format(
context.user.getPrivkey()))
context.print_buffer("Your peer's fingerprint is: {}".format(
context.print_buffer("Your peer's fingerprint is: {0}".format(
potr.human_hash(context.crypto.theirPubkey.cfingerprint())))
if context.is_verified():
context.print_buffer(
Loading
Loading
@@ -1463,7 +1464,7 @@ def command_cb(data, buf, args):
context.smpInit(secret, question)
except potr.context.NotEncryptedError:
context.print_buffer(
'There is currently no encrypted session with {}.'.format(
'There is currently no encrypted session with {0}.'.format(
context.peer), 'error')
else:
if question:
Loading
Loading
@@ -1490,7 +1491,7 @@ def command_cb(data, buf, args):
context.smpAbort()
except potr.context.NotEncryptedError:
context.print_buffer(
'There is currently no encrypted session with {}.'
'There is currently no encrypted session with {0}.'
.format(context.peer), 'error')
else:
debug('SMP aborted')
Loading
Loading
@@ -1826,7 +1827,7 @@ def buffer_closing_cb(data, signal, signal_data):
def init_config():
"""Set up configuration options and load config file."""
global CONFIG_FILE
CONFIG_FILE = weechat.config_new(SCRIPT_NAME, 'config_reload_cb', '')
CONFIG_FILE = weechat.config_new(SCRIPT_NAME, '', '')
 
global CONFIG_SECTIONS
CONFIG_SECTIONS = {}
Loading
Loading
@@ -1993,13 +1994,6 @@ def init_config():
 
weechat.config_read(CONFIG_FILE)
 
def config_reload_cb(data, config_file):
"""/reload callback to reload config from file."""
free_all_config()
init_config()
return weechat.WEECHAT_CONFIG_READ_OK
def free_all_config():
"""Free all config options, sections and config file."""
for section in CONFIG_SECTIONS.values():
Loading
Loading
@@ -2022,13 +2016,19 @@ def git_info():
if os.path.isdir(git_dir):
import subprocess
try:
result = PYVER.to_unicode(subprocess.check_output([
# We can't use check_output here without breaking compatibility
# for Python 2.6, but we ignore the return value anyway, so Popen
# is only slightly more complicated:
process = subprocess.Popen([
'git',
'--git-dir', git_dir,
'--work-tree', script_dir,
'describe', '--dirty', '--always',
])).lstrip('v').rstrip()
except (OSError, subprocess.CalledProcessError):
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output = process.communicate()[0]
if output:
result = PYVER.to_unicode(output).lstrip('v').rstrip()
except OSError:
pass
 
return result
Loading
Loading
"""
Copyright (c) 2014 by Vlad Stoica <stoica.vl@gmail.com>
Copyright (c) 2014-2018 by Vlad Stoica <stoica.vl@gmail.com>
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Loading
Loading
@@ -21,127 +21,194 @@ Uses a sqlite3 database to store triggers with the replies, has the
ability to ignore channels.
16-08-2015 - Vlad Stoica
Fixed a bug where replies couldn't have `:' in them.
15-02-2018 - Vlad Stoica
Added regex support in triggers, and edited syntax of adding triggers.
The command is now 'add "trigger" "reply"'. Quote marks can be escaped
in triggers or replies by prefixing them with a backslash ('\'). For
example, 'add "\"picture\"" "say \"cheese\"!"' is a valid command and
will reply with 'say "cheese"!' whenever it finds '"picture"' sent.
 
Bugs: not that i'm aware of.
"""
 
#pylint: disable-msg=too-many-arguments
try:
import weechat
import sqlite3
IMPORT_ERR = 0
import re
except ImportError:
IMPORT_ERR = 1
raise ImportError("Failed importing weechat, sqlite3, re")
import os
 
SCRIPT_NAME = "triggerreply"
SCRIPT_AUTHOR = "Vlad Stoica <stoica.vl@gmail.com>"
SCRIPT_VERSION = "0.2"
SCRIPT_VERSION = "0.3"
SCRIPT_LICENSE = "GPL3"
SCRIPT_DESC = "Auto replies when someone sends a specified trigger."
SCRIPT_DESC = "Auto replies when someone sends a specified trigger. Now with 100% more regex!"
 
def phelp():
def print_help():
""" print the help message """
weechat.prnt("", "Triggerreply (trigge.rs) plugin. Automatically \
replies over specified triggers")
weechat.prnt("", "------------")
weechat.prnt("", "Usage: /triggerreply [list | add trigger:reply \
| remove trigger | ignore server.#channel | parse server.#channel]")
weechat.prnt("", """
Triggerreply (trigge.rs) plugin. Automatically replies over specified triggers.
------------
Usage: /triggerreply [list | add | remove | ignore | parse] ARGUMENTS
Commands:
list - lists the triggers with replies, and ignored channels
add - two arguments: "trigger" and "reply"
- adds a trigger with the specified reply
- if '-r' is specified, then the trigger will be parsed as regular expression
remove - one argument: "trigger"
- remove a trigger
ignore - one argument: "server.#channel"
- ignores a particular channel from a server
parse - one argument: "server.#channel"
- removes a channel from ignored list
Examples:
/triggerreply add "^[Hh](i|ello|ey)[ .!]*" "Hey there!"
/triggerreply add "lol" "not funny tho"
/triggerreply remove lol
/triggerreply ignore rizon.#help
/triggerreply parse rizon.#help
""")
 
def create_db():
def create_db(delete=False):
""" create the sqlite database """
tmpcon = sqlite3.connect(DBFILE)
cur = tmpcon.cursor()
if delete:
os.remove(db_file)
temp_con = sqlite3.connect(db_file)
cur = temp_con.cursor()
cur.execute("CREATE TABLE triggers(id INTEGER PRIMARY KEY, trig VARCHAR, reply VARCHAR);")
cur.execute("INSERT INTO triggers(trig, reply) VALUES ('trigge.rs', 'Automatic reply');")
cur.execute("CREATE TABLE banchans(id INTEGER PRIMARY KEY, ignored VARCHAR);")
cur.execute("INSERT INTO banchans(ignored) VALUES ('rizon.#help');")
tmpcon.commit()
temp_con.commit()
cur.close()
 
def search_trig_cb(data, buffer, date, tags, displayed, highlight, prefix, message):
def search_trig_cb(data, buf, date, tags, displayed, highlight, prefix, message):
""" function for parsing sent messages """
database = sqlite3.connect(DBFILE)
if weechat.buffer_get_string(buf, "name") == 'weechat':
return weechat.WEECHAT_RC_OK
database = sqlite3.connect(db_file)
database.text_factory = str
cursor = database.cursor()
ignored_chan = False
for row in cursor.execute("SELECT ignored from banchans;"):
if weechat.buffer_get_string(buffer, "name") == row[0]:
ignored_chan = True
if not ignored_chan:
for row in cursor.execute("SELECT reply FROM triggers WHERE trig = ?", (str(message),)):
weechat.command(buffer, "/say %s" % row)
if weechat.buffer_get_string(buf, "name") == row[0]:
return weechat.WEECHAT_RC_OK
for row in cursor.execute("SELECT * FROM triggers"):
try:
r = re.compile(row[1])
if r.search(message) is not None:
weechat.command(buf, "/say %s" % row[2])
except:
if row[1] == message:
weechat.command(buf, "/say %s" % row[2])
return weechat.WEECHAT_RC_OK
 
def command_input_callback(data, buffer, argv):
""" function called when `/triggerreply args' is run """
database = sqlite3.connect(DBFILE)
database = sqlite3.connect(db_file)
cursor = database.cursor()
command = argv.split()
if len(command) == 0:
phelp()
elif command[0] == "list":
print_help()
return weechat.WEECHAT_RC_ERROR
if command[0] == "list":
weechat.prnt("", "List of triggers with replies:")
for row in cursor.execute("SELECT * FROM triggers;"):
weechat.prnt("", str(row[0]) + ". " + row[1] + " -> " + row[2])
weechat.prnt("", "\nList of ignored channels:")
for row in cursor.execute("SELECT ignored FROM banchans;"):
weechat.prnt("", row[0])
elif command[0] == "add":
if len(argv) == len(command[0]):
print_help()
return weechat.WEECHAT_RC_ERROR
if argv.count('"') < 4:
print_help()
return weechat.WEECHAT_RC_ERROR
pos = []
for k, v in enumerate(argv):
if v == '"' and argv[k - 1] != '\\':
pos.append(k)
if len(pos) != 4:
print_help()
return weechat.WEECHAT_RC_ERROR
trigger = argv[pos[0] + 1:pos[1]].replace('\\"', '"')
reply = argv[pos[2] + 1:pos[3]].replace('\\"', '"')
try:
trigger = argv[4:].split(":")[0]
#reply = ''.join(argv[4:].split(":")[1:])
reply = argv[4:].replace(trigger+":", '')
cursor.execute("INSERT INTO triggers(trig, reply) VALUES (?,?)", (trigger, reply,))
except:
weechat.prnt("", "Could not add trigger.\n")
weechat.prnt("", "Usage: /triggerreply add trigger:reply")
weechat.prnt("", "Example: /triggerreply add lol:hue hue")
else:
database.commit()
weechat.prnt("", "Trigger added successfully!")
print_help()
return weechat.WEECHAT_RC_ERROR
database.commit()
weechat.prnt("", "Trigger added successfully!")
elif command[0] == "remove":
if len(argv) == len(command[0]):
print_help()
return weechat.WEECHAT_RC_ERROR
try:
cursor.execute("DELETE FROM triggers WHERE trig = ?", (argv[7:],))
except:
weechat.prnt("", "Could not remove trigger.")
weechat.prnt("", "Usage: /triggerreply remove trigger")
weechat.prnt("", "Example: /triggerreply remove hue")
else:
database.commit()
weechat.prnt("", "Trigger successfully removed.")
print_help()
return weechat.WEECHAT_RC_ERROR
database.commit()
weechat.prnt("", "Trigger successfully removed.")
elif command[0] == "ignore":
if len(argv) == len(command[0]):
print_help()
return weechat.WEECHAT_RC_ERROR
try:
cursor.execute("INSERT INTO banchans(ignored) VALUES (?)", (command[1],))
except:
weechat.prnt("", "Could not add channel to ignored list.")
weechat.prnt("", "Usage: /triggerreply ignore server.#channel")
weechat.prnt("", "Example: /triggerreply ignore freenode.#mychan")
else:
database.commit()
weechat.prnt("", "Channel successfully added to ignore list!")
print_help()
return weechat.WEECHAT_RC_ERROR
database.commit()
weechat.prnt("", "Channel successfully added to ignore list!")
elif command[0] == "parse":
if len(argv) == len(command[0]):
print_help()
return weechat.WEECHAT_RC_ERROR
try:
cursor.execute("DELETE FROM banchans WHERE ignored = ?", (command[1],))
except:
weechat.prnt("", "Could not remove channel from ignored.")
weechat.prnt("", "Usage: /triggerreply parse server.#channel")
weechat.prnt("", "Example: /triggerreply parse freenode.#mychan")
else:
database.commit()
weechat.prnt("", "Channel successfully removed from ignored.")
print_help()
return weechat.WEECHAT_RC_ERROR
database.commit()
weechat.prnt("", "Channel successfully removed from ignored.")
return weechat.WEECHAT_RC_OK
 
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC,
"", ""):
if IMPORT_ERR:
weechat.prnt("", "You need sqlite3 to run this plugin.")
DBFILE = "%s/trigge.rs" % weechat.info_get("weechat_dir", "")
if not os.path.isfile(DBFILE):
create_db()
 
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
db_file = "%s/trigge.rs" % weechat.info_get("weechat_dir", "")
if not os.path.isfile(db_file):
create_db()
 
weechat.hook_print("", "", "", 1, "search_trig_cb", "")
weechat.hook_command(SCRIPT_NAME, SCRIPT_DESC, "See `/triggerreply' for more information.", "",
"", "command_input_callback", "")
weechat.hook_command(SCRIPT_NAME, SCRIPT_DESC, "See `/triggerreply' for more information.", "", "",
"command_input_callback", "")
Loading
Loading
@@ -120,6 +120,8 @@
# for '/url copy'
# - V2.8 Simmo Saan <simmo.saan@gmail.com>:
# - Changed print hook to ignore filtered lines
# - V2.9 Dominik Heidler <dominik@heidler.eu>:
# - Updated script for python3 support (now python2 and 3 are both supported)
#
# Copyright (C) 2005 David Rubin <drubin AT smartcube dot co dot za>
#
Loading
Loading
@@ -139,20 +141,27 @@
# USA.
#
 
from __future__ import print_function
import sys
import os
try:
import weechat
import_ok = True
except:
print "This script must be run under WeeChat."
print "Get WeeChat now at: http://www.weechat.org/"
print("This script must be run under WeeChat.")
print("Get WeeChat now at: http://www.weechat.org/")
import_ok = False
import subprocess
import time
import urllib
try:
from urllib import quote
except ImportError:
from urllib.parse import quote
import re
from UserDict import UserDict
try:
from UserDict import UserDict
except ImportError:
from collections import UserDict
 
 
octet = r'(?:2(?:[0-4]\d|5[0-5])|1\d\d|\d{1,2})'
Loading
Loading
@@ -165,7 +174,7 @@ urlRe = re.compile(r'(\w+://(?:%s|%s)(?::\d+)?(?:/[^\]>\s]*)?)' % (domain, ipAdd
 
SCRIPT_NAME = "urlgrab"
SCRIPT_AUTHOR = "David Rubin <drubin [At] smartcube [dot] co [dot] za>"
SCRIPT_VERSION = "2.8"
SCRIPT_VERSION = "2.9"
SCRIPT_LICENSE = "GPL"
SCRIPT_DESC = "Url functionality Loggin, opening of browser, selectable links"
CONFIG_FILE_NAME= "urlgrab"
Loading
Loading
@@ -358,7 +367,7 @@ class UrlGrabber:
index['buffer'], index['url']))
dout.close()
except :
print "failed to log url check that %s is valid path" % urlGrabSettings['url_log']
print("failed to log url check that %s is valid path" % urlGrabSettings['url_log'])
pass
 
# check for buffer
Loading
Loading
@@ -452,7 +461,7 @@ def urlGrabCopy(bufferd, index):
 
def urlGrabOpenUrl(url):
global urlGrab, urlGrabSettings
argl = urlGrabSettings.createCmd( urllib.quote(url, '/:#%?&+=') )
argl = urlGrabSettings.createCmd( quote(url, '/:#%?&+=') )
weechat.hook_process(argl,60000, "ug_open_cb", "")
 
def ug_open_cb(data, command, code, out, err):
Loading
Loading
@@ -684,4 +693,4 @@ if ( import_ok and
weechat.hook_completion("urlgrab_urls", "list of URLs",
"completion_urls_cb", "")
else:
print "failed to load weechat"
print("failed to load weechat")