Skip to content
Snippets Groups Projects
Commit 0cb77d2e authored by Nils Görs's avatar Nils Görs
Browse files

Merge branch 'master' of https://github.com/weechat/scripts

parents 14c8a810 f2ca0fef
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -31,11 +31,13 @@ Then the author will send a pull request on this repository.
 
There are two ways to send a new release for a script:
 
* Send a pull request, the commit message must have the name of script,
version, and changes, like that: +
* Send a pull request (*recommended*). +
The commit message must have the name of script, version, and changes,
like that: +
`script.py 0.3: fix...` +
Please submit only one script per pull request.
* Use the form at: <https://weechat.org/scripts/update/>.
Only one script is allowed per pull request.
* Use the form at: <https://weechat.org/scripts/update/> (please use this form
only if you can not send a pull request).
 
When sending a new version :
 
Loading
Loading
#
# Copyright (c) 2010-2015 by Nils Görs <weechatter@arcor.de>
# Copyright (c) 2010-2017 by Nils Görs <weechatter@arcor.de>
# Copyleft (ɔ) 2013 by oakkitten
#
# colors the channel text with nick color and also highlight the whole line
Loading
Loading
@@ -44,6 +44,7 @@
# /buffer set localvar_set_colorize_lines *yellow
 
# history:
# 3.5: new options "highlight_words" and "highlight_words_color" (idea by jokrebel)
# 3.4: new options "tags" and "ignore_tags"
# 3.3: use localvar "colorize_lines" for buffer related color (idea by tomoe-mami)
# 3.2: minor logic fix
Loading
Loading
@@ -106,29 +107,33 @@
 
use strict;
my $PRGNAME = "colorize_lines";
my $VERSION = "3.4";
my $VERSION = "3.5";
my $AUTHOR = "Nils Görs <weechatter\@arcor.de>";
my $LICENCE = "GPL3";
my $DESCR = "Colorize users' text in chat area with their nick color, including highlights";
 
my %config = ("buffers" => "all", # all, channel, query
"blacklist_buffers" => "", # "a,b,c"
"lines" => "on",
"highlight" => "on", # on, off, nicks
"nicks" => "", # "d,e,f", "/file"
"own_lines" => "on", # on, off, only
"tags" => "irc_privmsg",
"ignore_tags" => "irc_ctcp",
my %config = ("buffers" => "all", # all, channel, query
"blacklist_buffers" => "", # "a,b,c"
"lines" => "on",
"highlight" => "on", # on, off, nicks
"nicks" => "", # "d,e,f", "/file"
"own_lines" => "on", # on, off, only
"tags" => "irc_privmsg",
"ignore_tags" => "irc_ctcp",
"highlight_words" => "off", # on, off
"highlight_words_color" => "black,darkgray",
);
 
my %help_desc = ("buffers" => "Buffer type affected by the script (all/channel/query, default: all)",
"blacklist_buffers" => "Comma-separated list of channels to be ignored (e.g. freenode.#weechat,*.#python)",
"lines" => "Apply nickname color to the lines (off/on/nicks). The latter will limit highlighting to nicknames in option 'nicks'",
"highlight" => "Apply highlight color to the highlighted lines (off/on/nicks). The latter will limit highlighting to nicknames in option 'nicks'",
"nicks" => "Comma-separater list of nicks (e.g. freenode.cat,*.dog) OR file name starting with '/' (e.g. /file.txt). In the latter case, nicknames will get loaded from that file inside weechat folder (e.g. from ~/.weechat/file.txt). Nicknames in file are newline-separated (e.g. freenode.dog\\n*.cat)",
"own_lines" => "Apply nickname color to own lines (off/on/only). The latter turns off all other kinds of coloring altogether",
"tags" => "Comma-separated list of tags to accept (see /debug tags)",
"ignore_tags" => "Comma-separated list of tags to ignore (see /debug tags)",
my %help_desc = ("buffers" => "Buffer type affected by the script (all/channel/query, default: all)",
"blacklist_buffers" => "Comma-separated list of channels to be ignored (e.g. freenode.#weechat,*.#python)",
"lines" => "Apply nickname color to the lines (off/on/nicks). The latter will limit highlighting to nicknames in option 'nicks'",
"highlight" => "Apply highlight color to the highlighted lines (off/on/nicks). The latter will limit highlighting to nicknames in option 'nicks'",
"nicks" => "Comma-separater list of nicks (e.g. freenode.cat,*.dog) OR file name starting with '/' (e.g. /file.txt). In the latter case, nicknames will get loaded from that file inside weechat folder (e.g. from ~/.weechat/file.txt). Nicknames in file are newline-separated (e.g. freenode.dog\\n*.cat)",
"own_lines" => "Apply nickname color to own lines (off/on/only). The latter turns off all other kinds of coloring altogether",
"tags" => "Comma-separated list of tags to accept (see /debug tags)",
"ignore_tags" => "Comma-separated list of tags to ignore (see /debug tags)",
"highlight_words" => "highlight word(s) in text, matching word(s) in weechat.look.highlight",
"highlight_words_color" => "color for highlight word in text (fg:bg)",
);
 
my @ignore_tags_array;
Loading
Loading
@@ -223,12 +228,41 @@ sub colorize_cb
$color = $channel_color if ($channel_color);
} else {
# oh well
return $string;
return $string if ($config{highlight_words} ne "on");
}
}
my $right_nocolor = weechat::string_remove_color($right, "");
if ((
$config{highlight_words} eq "on"
) && ($my_nick ne $nick) && (
weechat::string_has_highlight($right_nocolor, weechat::config_string(weechat::config_get("weechat.look.highlight")))
))
{
my $high_word_color = weechat::color(weechat::config_get_plugin("highlight_words_color"));
my $reset = weechat::color('reset');
my @highlight_array = split(/,/,weechat::config_string(weechat::config_get("weechat.look.highlight")));
my @line_array = split(/ /,$right);
foreach my $l (@line_array) {
foreach my $h (@highlight_array) {
my $i = $h;
# check word case insensitiv || check if word matches without "(?-i)" at beginning
if ( lc($l) eq lc($h) || (index($h,"(?-i)") != -1 && ($l eq substr($i,5,length($i)-5,""))) ) {
$right =~ s/\Q$l\E/$high_word_color$l$reset/;
# word starts with (?-i) and has a wildcard ?
} elsif ((index($h,"(?-i)") != -1) && (index($h,"*") != -1) ){
my $i = $h;
my $t = substr($i,5,length($i)-5,"");
my $regex = weechat::string_mask_to_regex($t);
$right =~ s/\Q$l\E/$high_word_color$l$reset/ if ($l =~ /^$regex$/i); # use * without sensitive
}elsif ((index($h,"*") == 0 || index($h,"*") == length($h)-1)){# wildcard at beginning or end ?
my $regex = weechat::string_mask_to_regex($h);
$right =~ s/\Q$l\E/$high_word_color$l$reset/ if ($l =~ /^$regex$/i);
}
}
}
}
######################################## inject colors and go!
my $out = "";
if ($action) {
# remove the first color reset - after * nick
Loading
Loading
Loading
Loading
@@ -25,6 +25,13 @@
 
#
# Changelog:
# 3.3:
# * Fix the /autosort debug command for unicode.
# * Update the default rules to work better with Slack.
# 3.2:
# * Fix python3 compatiblity.
# 3.1:
# * Use colors to format the help text.
# 3.0:
# * Switch to evaluated expressions for sorting.
# * Add `/autosort debug` command.
Loading
Loading
@@ -58,12 +65,13 @@
import json
import math
import re
import sys
import time
import weechat
 
SCRIPT_NAME = 'autosort'
SCRIPT_AUTHOR = 'Maarten de Vries <maarten@de-vri.es>'
SCRIPT_VERSION = '3.0'
SCRIPT_VERSION = '3.3'
SCRIPT_LICENSE = 'GPL3'
SCRIPT_DESC = 'Flexible automatic (or manual) buffer sorting based on eval expressions.'
 
Loading
Loading
@@ -72,6 +80,25 @@ config = None
hooks = []
timer = None
 
# Make sure that unicode, bytes and str are always available in python2 and 3.
# For python 2, str == bytes
# For python 3, str == unicode
if sys.version_info[0] >= 3:
unicode = str
def ensure_str(input):
'''
Make sure the given type if the correct string type for the current python version.
That means bytes for python2 and unicode for python3.
'''
if not isinstance(input, str):
if isinstance(input, bytes):
return input.encode('utf-8')
if isinstance(input, unicode):
return input.decode('utf-8')
return input
if hasattr(time, 'perf_counter'):
perf_counter = time.perf_counter
else:
Loading
Loading
@@ -137,9 +164,9 @@ class Config:
'${irc_last}',
'${buffer.plugin.name}',
'${irc_raw_first}',
'${server}',
'${info:autosort_order,${type},server,*,channel,private}',
'${hashless_name}',
'${if:${plugin}==irc?${server}}',
'${if:${plugin}==irc?${info:autosort_order,${type},server,*,channel,private}}',
'${if:${plugin}==irc?${hashless_name}}',
'${buffer.full_name}',
])
 
Loading
Loading
@@ -395,12 +422,13 @@ def command_debug(buffer, command, args):
for merged in buffers:
for buffer in merged:
fullname = weechat.hdata_string(hdata, buffer, 'full_name')
if isinstance(fullname, bytes): fullname = fullname.decode('utf-8')
results.append((fullname, key(buffer)))
elapsed = perf_counter() - start
 
for fullname, result in results:
log('{0}: {1}'.format(fullname, result))
fullname = ensure_str(fullname)
result = [ensure_str(x) for x in result]
log('{0}: {1}'.format(fullname, result))
log('Computing evalutaion results took {0:.4f} seconds.'.format(elapsed))
 
return weechat.WEECHAT_RC_OK
Loading
Loading
@@ -734,95 +762,116 @@ def on_autosort_complete(data, name, buffer, completion):
return autosort_complete_helpers(words[1:], completion)
return weechat.WEECHAT_RC_OK
 
command_description = r'''
NOTE: For the best effect, you may want to consider setting the option irc.look.server_buffer to independent and buffers.look.indenting to on.
# Commands
command_description = r'''{*white}# General commands{reset}
 
## Miscellaneous
/autosort sort
{*white}/autosort {brown}sort{reset}
Manually trigger the buffer sorting.
 
/autosort debug
{*white}/autosort {brown}debug{reset}
Show the evaluation results of the sort rules for each buffer.
 
 
## Sorting rules
{*white}# Sorting rule commands{reset}
 
/autosort rules list
{*white}/autosort{brown} rules list{reset}
Print the list of sort rules.
 
/autosort rules add <expression>
{*white}/autosort {brown}rules add {cyan}<expression>{reset}
Add a new rule at the end of the list.
 
/autosort rules insert <index> <expression>
{*white}/autosort {brown}rules insert {cyan}<index> <expression>{reset}
Insert a new rule at the given index in the list.
 
/autosort rules update <index> <expression>
{*white}/autosort {brown}rules update {cyan}<index> <expression>{reset}
Update a rule in the list with a new expression.
 
/autosort rules delete <index>
{*white}/autosort {brown}rules delete {cyan}<index>
Delete a rule from the list.
 
/autosort rules move <index_from> <index_to>
{*white}/autosort {brown}rules move {cyan}<index_from> <index_to>{reset}
Move a rule from one position in the list to another.
 
/autosort rules swap <index_a> <index_b>
{*white}/autosort {brown}rules swap {cyan}<index_a> <index_b>{reset}
Swap two rules in the list
 
 
## Helper variables
{*white}# Helper variable commands{reset}
 
/autosort helpers list
{*white}/autosort {brown}helpers list
Print the list of helper variables.
 
/autosort helpers set <name> <expression>
{*white}/autosort {brown}helpers set {cyan}<name> <expression>
Add or update a helper variable with the given name.
 
/autosort helpers delete <named>
{*white}/autosort {brown}helpers delete {cyan}<name>
Delete a helper variable.
 
/autosort helpers rename <old_name> <new_name>
{*white}/autosort {brown}helpers rename {cyan}<old_name> <new_name>
Rename a helper variable.
 
/autosort helpers swap <name_a> <name_b>
{*white}/autosort {brown}helpers swap {cyan}<name_a> <name_b>
Swap the expressions of two helper variables in the list.
 
 
# Introduction
Autosort is a weechat script to automatically keep your buffers sorted.
The sort order can be customized by defining your own sort rules,
but the default should be sane enough for most people.
It can also group IRC channel/private buffers under their server buffer if you like.
## Sort rules
Autosort evaluates a list of eval expressions (see /help eval) and sorts the buffers based on evaluated result.
Earlier rules will be considered first.
Only if earlier rules produced identical results is the result of the next rule considered for sorting purposes.
You can debug your sort rules with the `/autosort debug` command, which will print the evaluation results of each rule for each buffer.
NOTE: The sort rules for version 3 are not compatible with version 2 or vice versa.
You will have to manually port your old rules to version 3 if you have any.
## Helper variables
You may define helper variables for the main sort rules to keep your rules readable.
They can be used in the main sort rules as variables.
For example, a helper variable named `foo` can be accessed in a main rule with the string `${foo}`.
## Replacing substrings
There is no default method for replacing text inside eval expressions.
However, autosort adds a `replace` info hook that can be used inside eval expressions: `${info:autosort_replace,from,to,text}`.
For example, `${info:autosort_replace,#,,${buffer.name}}` will evaluate to the buffer name with all hash signs stripped.
You can escape commas and backslashes inside the arguments by prefixing them with a backslash.
## Automatic or manual sorting
By default, autosort will automatically sort your buffer list whenever a buffer is opened, merged, unmerged or renamed.
This should keep your buffers sorted in almost all situations.
However, you may wish to change the list of signals that cause your buffer list to be sorted.
Simply edit the "autosort.sorting.signals" option to add or remove any signal you like.
If you remove all signals you can still sort your buffers manually with the "/autosort sort" command.
To prevent all automatic sorting, "autosort.sorting.sort_on_config_change" should also be set to off.
{*white}# Description
Autosort is a weechat script to automatically keep your buffers sorted. The sort
order can be customized by defining your own sort rules, but the default should
be sane enough for most people. It can also group IRC channel/private buffers
under their server buffer if you like.
{*white}# Sort rules{reset}
Autosort evaluates a list of eval expressions (see {*default}/help eval{reset}) and sorts the
buffers based on evaluated result. Earlier rules will be considered first. Only
if earlier rules produced identical results is the result of the next rule
considered for sorting purposes.
You can debug your sort rules with the `{*default}/autosort debug{reset}` command, which will
print the evaluation results of each rule for each buffer.
{*brown}NOTE:{reset} The sort rules for version 3 are not compatible with version 2 or vice
versa. You will have to manually port your old rules to version 3 if you have any.
{*white}# Helper variables{reset}
You may define helper variables for the main sort rules to keep your rules
readable. They can be used in the main sort rules as variables. For example,
a helper variable named `{cyan}foo{reset}` can be accessed in a main rule with the
string `{cyan}${{foo}}{reset}`.
{*white}# Replacing substrings{reset}
There is no default method for replacing text inside eval expressions. However,
autosort adds a `replace` info hook that can be used inside eval expressions:
{cyan}${{info:autosort_replace,from,to,text}}{reset}
For example, to strip all hashes from a buffer name, you could write:
{cyan}${{info:autosort_replace,#,,${{buffer.name}}}}{reset}
You can escape commas and backslashes inside the arguments by prefixing them with
a backslash.
{*white}# Automatic or manual sorting{reset}
By default, autosort will automatically sort your buffer list whenever a buffer
is opened, merged, unmerged or renamed. This should keep your buffers sorted in
almost all situations. However, you may wish to change the list of signals that
cause your buffer list to be sorted. Simply edit the `{cyan}autosort.sorting.signals{reset}`
option to add or remove any signal you like.
If you remove all signals you can still sort your buffers manually with the
`{*default}/autosort sort{reset}` command. To prevent all automatic sorting, the option
`{cyan}autosort.sorting.sort_on_config_change{reset}` should also be disabled.
{*white}# Recommended settings
For the best visual effect, consider setting the following options:
{*white}/set {cyan}irc.look.server_buffer{reset} {brown}independent{reset}
{*white}/set {cyan}buffers.look.indenting{reset} {brown}on{reset}
The first setting allows server buffers to be sorted independently, which is
needed to create a hierarchical tree view of the server and channel buffers.
The second one indents channel and private buffers in the buffer list of the
`{*default}buffers.pl{reset}` script.
If you are using the {*default}buflist{reset} plugin you can (ab)use Unicode to draw a tree
structure with the following setting (modify to suit your need):
{*white}/set {cyan}buflist.format.indent {brown}"${{color:237}}${{if:${{buffer.next_buffer.local_variables.type}}=~^(channel|private)$?├─:└─}}"{reset}
'''
 
command_completion = '%(plugin_autosort) %(plugin_autosort) %(plugin_autosort) %(plugin_autosort) %(plugin_autosort)'
Loading
Loading
@@ -841,9 +890,33 @@ info_order_arguments = 'value,first,second,third,...'
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
config = Config('autosort')
 
colors = {
'default': weechat.color('default'),
'reset': weechat.color('reset'),
'black': weechat.color('black'),
'red': weechat.color('red'),
'green': weechat.color('green'),
'brown': weechat.color('brown'),
'yellow': weechat.color('yellow'),
'blue': weechat.color('blue'),
'magenta': weechat.color('magenta'),
'cyan': weechat.color('cyan'),
'white': weechat.color('white'),
'*default': weechat.color('*default'),
'*black': weechat.color('*black'),
'*red': weechat.color('*red'),
'*green': weechat.color('*green'),
'*brown': weechat.color('*brown'),
'*yellow': weechat.color('*yellow'),
'*blue': weechat.color('*blue'),
'*magenta': weechat.color('*magenta'),
'*cyan': weechat.color('*cyan'),
'*white': weechat.color('*white'),
}
weechat.hook_config('autosort.*', 'on_config_changed', '')
weechat.hook_completion('plugin_autosort', '', 'on_autosort_complete', '')
weechat.hook_command('autosort', command_description, '', '', command_completion, 'on_autosort_command', '')
weechat.hook_command('autosort', command_description.format(**colors), '', '', command_completion, 'on_autosort_command', '')
weechat.hook_info('autosort_replace', info_replace_description, info_replace_arguments, 'on_info_replace', '')
weechat.hook_info('autosort_order', info_order_description, info_order_arguments, 'on_info_order', '')
 
Loading
Loading
Loading
Loading
@@ -17,6 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# 2017-12-14: Sébastien Helleu <flashcode@flashtux.org>
# 0.6 : rename command "/autosetbuffer" by "/buffer_autoset" in example
#
# 2015-04-05: nils_2 (freenode.#weechat)
# 0.5 : change priority of hook_signal('buffer_opened') to 100
#
Loading
Loading
@@ -49,7 +52,7 @@ except Exception:
 
SCRIPT_NAME = 'histman'
SCRIPT_AUTHOR = 'nils_2 <weechatter@arcor.de>'
SCRIPT_VERSION = '0.5'
SCRIPT_VERSION = '0.6'
SCRIPT_LICENSE = 'GPL'
SCRIPT_DESC = 'save and restore global and/or buffer command history'
 
Loading
Loading
@@ -395,9 +398,9 @@ if __name__ == '__main__':
' save the command history manually (for example with /cron script):\n'
' /' + SCRIPT_NAME + ' save\n'
' save and restore command history for buffer #weechat on freenode (text only):\n'
' /autosetbuffer add irc.freenode.#weechat localvar_set_save_history text\n'
' /buffer_autoset add irc.freenode.#weechat localvar_set_save_history text\n'
' save and restore command history for weechat core buffer (commands only):\n'
' /autosetbuffer add core.weechat localvar_set_save_history command\n',
' /buffer_autoset add core.weechat localvar_set_save_history command\n',
'save %-'
'|| list %-',
'histman_cmd_cb', '')
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ import json
 
SCRIPT_NAME = 'mqtt_notify'
SCRIPT_AUTHOR = 'Guillaume Subiron <maethor@subiron.org>'
SCRIPT_VERSION = '0.1'
SCRIPT_VERSION = '0.2'
SCRIPT_LICENSE = 'WTFPL'
SCRIPT_DESC = 'Sends notifications using MQTT'
 
Loading
Loading
@@ -44,7 +44,7 @@ def on_msg(*a):
msg['buffer'] = w.buffer_get_string(msg['buffer'], 'short_name')
 
cli = mqtt.Client()
if w.config.get_plugin('mqtt_user'):
if w.config_get_plugin('mqtt_user'):
cli.username_pw_set(w.config_get_plugin('mqtt_user'),
password=w.config_get_plugin('mqtt_password'))
cli.connect(w.config_get_plugin('mqtt_host'),
Loading
Loading
Loading
Loading
@@ -2,9 +2,9 @@ import weechat as w
 
SCRIPT_NAME = "noirccolors"
SCRIPT_AUTHOR = "Fredrick Brennan <fredrick.brennan1@gmail.com>"
SCRIPT_VERSION = "0.2"
SCRIPT_VERSION = "0.3"
SCRIPT_LICENSE = "Public domain"
SCRIPT_DESC = "Remove IRC colors from buffers with the localvar 'noirccolors' set. To disable IRC colors in the current buffer, type /buffer set localvar_set_noirccolors true. You can also set this with autosetbuffer. :)"
SCRIPT_DESC = "Remove IRC colors from buffers with the localvar 'noirccolors' set. To disable IRC colors in the current buffer, type /buffer set localvar_set_noirccolors true. You can also set this with script buffer_autoset.py. :)"
 
w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', '')
 
Loading
Loading
Loading
Loading
@@ -24,6 +24,10 @@
# (this script requires WeeChat 0.3.0 or newer)
#
# History:
# 2017-11-20, Nils Görs <weechatter@arcor.de>
# version 0.15: make script python3 compatible
# : fix problem with empty "command_on_*" options
# : add option "no_output"
# 2014-08-02, Nils Görs <weechatter@arcor.de>
# version 0.14: add time to detach message. (idea by Mikaela)
# 2014-06-19, Anders Bergh <anders1@gmail.com>
Loading
Loading
@@ -66,7 +70,7 @@ import datetime, time
 
SCRIPT_NAME = "screen_away"
SCRIPT_AUTHOR = "xt <xt@bash.no>"
SCRIPT_VERSION = "0.14"
SCRIPT_VERSION = "0.15"
SCRIPT_LICENSE = "GPL3"
SCRIPT_DESC = "Set away status on screen detach"
 
Loading
Loading
@@ -80,6 +84,7 @@ settings = {
'ignore': ('', 'Comma-separated list of servers to ignore.'),
'set_away': ('on', 'Set user as away.'),
'ignore_relays': ('off', 'Only check screen status and ignore relay interfaces'),
'no_output': ('off','no detach/attach information will be displayed in buffer'),
}
 
TIMER = None
Loading
Loading
@@ -144,7 +149,8 @@ def screen_away_timer_cb(buffer, args):
w.infolist_free(infolist)
 
if (attached and AWAY) or (check_relays and CONNECTED_RELAY and not attached and AWAY):
w.prnt('', '%s: Screen attached. Clearing away status' % SCRIPT_NAME)
if not w.config_string_to_boolean(w.config_get_plugin('no_output')):
w.prnt('', '%s: Screen attached. Clearing away status' % SCRIPT_NAME)
for server, nick in get_servers():
if set_away:
w.command(server, "/away")
Loading
Loading
@@ -152,20 +158,23 @@ def screen_away_timer_cb(buffer, args):
nick = nick[:-len(suffix)]
w.command(server, "/nick %s" % nick)
AWAY = False
for cmd in w.config_get_plugin("command_on_attach").split(";"):
w.command("", cmd)
if w.config_get_plugin("command_on_attach"):
for cmd in w.config_get_plugin("command_on_attach").split(";"):
w.command("", cmd)
 
elif not attached and not AWAY:
if not CONNECTED_RELAY:
w.prnt('', '%s: Screen detached. Setting away status' % SCRIPT_NAME)
if not w.config_string_to_boolean(w.config_get_plugin('no_output')):
w.prnt('', '%s: Screen detached. Setting away status' % SCRIPT_NAME)
for server, nick in get_servers():
if suffix and not nick.endswith(suffix):
w.command(server, "/nick %s%s" % (nick, suffix));
if set_away:
w.command(server, "/away %s %s" % (w.config_get_plugin('message'), time.strftime(w.config_get_plugin('time_format'))))
AWAY = True
for cmd in w.config_get_plugin("command_on_detach").split(";"):
w.command("", cmd)
if w.config_get_plugin("command_on_detach"):
for cmd in w.config_get_plugin("command_on_detach").split(";"):
w.command("", cmd)
 
return w.WEECHAT_RC_OK
 
Loading
Loading
@@ -173,7 +182,7 @@ def screen_away_timer_cb(buffer, args):
if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
SCRIPT_DESC, "", ""):
version = w.info_get('version_number', '') or 0
for option, default_desc in settings.iteritems():
for option, default_desc in settings.items():
if not w.config_is_set_plugin(option):
w.config_set_plugin(option, default_desc[0])
if int(version) >= 0x00030500:
Loading
Loading
Loading
Loading
@@ -20,6 +20,9 @@
#
# idea by shad0VV@freenode.#weechat
#
# 2017-12-14: Sébastien Helleu <flashcode@flashtux.org>
# 0.6 : rename command "/autosetbuffer" by "/buffer_autoset" in example
#
# 2017-04-02: nils_2, (freenode.#weechat)
# 0.5 : support of "/input jump_smart" and "/buffer +/-" (reported: squigz)
#
Loading
Loading
@@ -52,7 +55,7 @@ except Exception:
 
SCRIPT_NAME = "stick_buffer"
SCRIPT_AUTHOR = "nils_2 <weechatter@arcor.de>"
SCRIPT_VERSION = "0.5"
SCRIPT_VERSION = "0.6"
SCRIPT_LICENSE = "GPL"
SCRIPT_DESC = "Stick buffers to particular windows, like irssi"
 
Loading
Loading
@@ -239,7 +242,7 @@ Examples:
Stick buffer #weechat to window 2:
/buffer #weechat
/buffer set localvar_set_stick_buffer_to_window 2
/autosetbuffer add irc.freenode.#weechat stick_buffer_to_window 2
/buffer_autoset add irc.freenode.#weechat stick_buffer_to_window 2
Set the default stick-to window to window 5:
/set plugins.var.python.{script_name}.default_stick_window 5
List buffers with persistent stickiness:
Loading
Loading
Loading
Loading
@@ -26,9 +26,12 @@
# settings:
# plugins.var.python.twitch.servers (default: twitch)
# plugins.var.python.twitch.prefix_nicks (default: 1)
# plugins.var.python.twitch.debug (default: 0)
#
# # History:
#
# 2017-11-02, mumixam
# v0.4: added debug mode for API calls, minor bugfixes
# 2017-06-10, mumixam
# v0.3: fixed whois output of utf8 display names
# 2016-11-03, mumixam
Loading
Loading
@@ -40,12 +43,13 @@
 
SCRIPT_NAME = "twitch"
SCRIPT_AUTHOR = "mumixam"
SCRIPT_VERSION = "0.3"
SCRIPT_VERSION = "0.4"
SCRIPT_LICENSE = "GPL3"
SCRIPT_DESC = "twitch.tv Chat Integration"
OPTIONS={
'servers': ('twitch','Name of server(s) which script will be active on, space seperated'),
'prefix_nicks': ('1','Prefix nicks based on ircv3 tags for mods/subs, This can be cpu intensive on very active chats [1 for enabled, 0 for disabled]')
'prefix_nicks': ('1','Prefix nicks based on ircv3 tags for mods/subs, This can be cpu intensive on very active chats [1 for enabled, 0 for disabled]'),
'debug': ('0','Debug mode')
}
 
 
Loading
Loading
@@ -59,7 +63,7 @@ import ast
 
clientid='awtv6n371jb7uayyc4jaljochyjbfxs'
params = '?client_id='+clientid
curlopt = {"timeout": "5"}
def days_hours_minutes(td):
age = ''
hours = td.seconds // 3600
Loading
Loading
@@ -82,8 +86,8 @@ def twitch_main(data, buffer, args):
if not (server in OPTIONS['servers'].split() and type == 'channel'):
return weechat.WEECHAT_RC_OK
url = 'https://api.twitch.tv/kraken/streams/' + username
url_hook_process = weechat.hook_process(
"url:" + url+params, 7 * 1000, "stream_api", buffer)
weechat.hook_process_hashtable(
"url:" + url+params, curlopt, 7 * 1000, "stream_api", buffer)
return weechat.WEECHAT_RC_OK
 
 
Loading
Loading
@@ -114,7 +118,12 @@ def channel_api(data, command, rc, stdout, stderr):
try:
jsonDict = json.loads(stdout.strip())
except Exception as e:
weechat.prnt(data['buffer'], 'TWITCH: Error with twitch API')
weechat.prnt(data['buffer'], '%stwitch.py: error communicating with twitch api' % weechat.prefix('error'))
if OPTIONS['debug']:
weechat.prnt(data['buffer'],'%stwitch.py: return code: %s' % (weechat.prefix('error'),rc))
weechat.prnt(data['buffer'],'%stwitch.py: stdout: %s' % (weechat.prefix('error'),stdout))
weechat.prnt(data['buffer'],'%stwitch.py: stderr: %s' % (weechat.prefix('error'),stderr))
weechat.prnt(data['buffer'],'%stwitch.py: exception: %s' % (weechat.prefix('error'),e))
return weechat.WEECHAT_RC_OK
currentbuf = weechat.current_buffer()
name = data['name']
Loading
Loading
@@ -144,8 +153,8 @@ def channel_api(data, command, rc, stdout, stderr):
weechat.prnt(data['buffer'], makeutf8(output))
url = 'https://api.twitch.tv/kraken/users/' + \
name.lower() + '/follows/channels'
urlh = weechat.hook_process(
"url:" + url+params, 7 * 1000, "channel_api", str({'buffer': currentbuf, 'name': name, 'dname': dname}))
weechat.hook_process_hashtable(
"url:" + url+params, curlopt, 7 * 1000, "channel_api", str({'buffer': currentbuf, 'name': name, 'dname': dname}))
 
if len(jsonDict) == 18:
dname = jsonDict['display_name']
Loading
Loading
@@ -168,8 +177,8 @@ def channel_api(data, command, rc, stdout, stderr):
pcolor, pformat, dcolor, ncolor, user, dcolor, ccolor))
else:
url = 'https://api.twitch.tv/api/channels/' + data['name'].lower()
urlh = weechat.hook_process(
"url:" + url+params, 7 * 1000, "channel_api", str({'buffer': currentbuf, 'name': name, 'dname': data['name']}))
weechat.hook_process_hashtable(
"url:" + url+params, curlopt, 7 * 1000, "channel_api", str({'buffer': currentbuf, 'name': name, 'dname': data['name']}))
count = jsonDict['_total']
if count:
output = '%s%s %s[%s%s%s]%s %sFollowing%s: %s' % (
Loading
Loading
@@ -182,7 +191,12 @@ def stream_api(data, command, rc, stdout, stderr):
try:
jsonDict = json.loads(stdout.strip())
except Exception as e:
weechat.prnt(data, 'TWITCH: Error with twitch API')
weechat.prnt(data, '%stwitch.py: error communicating with twitch api' % weechat.prefix('error'))
if OPTIONS['debug']:
weechat.prnt(data,'%stwitch.py: return code: %s' % (weechat.prefix('error'),rc))
weechat.prnt(data,'%stwitch.py: stdout: %s' % (weechat.prefix('error'),stdout))
weechat.prnt(data,'%stwitch.py: stderr: %s' % (weechat.prefix('error'),stderr))
weechat.prnt(data,'%stwitch.py: exception: %s' % (weechat.prefix('error'),e))
return weechat.WEECHAT_RC_OK
currentbuf = weechat.current_buffer()
title_fg = weechat.color(
Loading
Loading
@@ -206,7 +220,7 @@ def stream_api(data, command, rc, stdout, stderr):
weechat.prnt(data, 'ERROR: The page could not be found, or has been deleted by its owner.')
return weechat.WEECHAT_RC_OK
if not 'stream' in jsonDict.keys():
weechat.prnt(data, 'TWITCH: Error with twitch API')
weechat.prnt(data, 'twitch.py: Error with twitch API (stream key missing from json)')
return weechat.WEECHAT_RC_OK
if not jsonDict['stream']:
line = "STREAM: %sOFFLINE%s %sCHECKED AT: %s" % (
Loading
Loading
@@ -291,7 +305,7 @@ def twitch_clearchat(data, modifier, modifier_data, string):
rul = weechat.color("-underline")
if user:
if 'ban-duration' in tags:
if tags['ban-reason']:
if 'ban-reason' in tags and tags['ban-reason']:
bn=tags['ban-reason'].replace('\s',' ')
weechat.prnt(buffer,"%s--%s %s has been timed out for %s seconds %sReason%s: %s" %
(pcolor, ccolor, user, tags['ban-duration'], ul, rul, bn))
Loading
Loading
@@ -402,7 +416,7 @@ def twitch_privmsg(data, modifier, server_name, string):
'irc_message_parse', {"message": string})
if message['channel'].startswith('#'):
return string
newmsg = 'PRIVMSG jtv :.w ' + message['nick'] + ' ' + message['text']
newmsg = 'PRIVMSG #%s :/w %s %s' % (message['nick'],message['nick'],message['text'])
return newmsg
 
 
Loading
Loading
@@ -438,8 +452,8 @@ def twitch_whois(data, modifier, server_name, string):
username = msg['nick'].lower()
currentbuf = weechat.current_buffer()
url = 'https://api.twitch.tv/kraken/channels/' + username
url_hook = weechat.hook_process(
"url:" + url+params, 7 * 1000, "channel_api", str({'buffer': currentbuf, 'name': username}))
url_hook = weechat.hook_process_hashtable(
"url:" + url+params, curlopt, 7 * 1000, "channel_api", str({'buffer': currentbuf, 'name': username}))
return ""
 
def config_setup():
Loading
Loading
@@ -449,7 +463,7 @@ def config_setup():
weechat.config_set_plugin(option, value[0])
OPTIONS[option] = value[0]
else:
if option == 'prefix_nicks':
if option == 'prefix_nicks' or option == 'debug':
OPTIONS[option] = weechat.config_string_to_boolean(
weechat.config_get_plugin(option))
else:
Loading
Loading
@@ -457,7 +471,7 @@ def config_setup():
 
def config_change(pointer, name, value):
option = name.replace('plugins.var.python.'+SCRIPT_NAME+'.','')
if option == 'prefix_nicks':
if option == 'prefix_nicks' or option == 'debug':
value=weechat.config_string_to_boolean(value)
OPTIONS[option] = value
return weechat.WEECHAT_RC_OK
Loading
Loading
@@ -469,6 +483,7 @@ if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
" settings:\n"
" plugins.var.python.twitch.servers (default: twitch)\n"
" plugins.var.python.twitch.prefix_nicks (default: 1)\n"
" plugins.var.python.twitch.debug (default: 0)\n"
"\n\n"
" This script checks stream status of any channel on any servers listed\n"
" in the \"plugins.var.python.twitch.servers\" setting. When you switch\n"
Loading
Loading
@@ -482,12 +497,15 @@ if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
"\n\n"
" This script also will prefix users nicks (@ for mod, % for sub,\n"
" and ~ for broadcaster). This will break the traditional function\n"
" of /ignore add nightbot and will require you to prefix nicks if you\n"
" want to ignore someone /ignore add re:[~@%]{0,3}nightbot should ignore\n"
" of `/ignore add nightbot` and will require you to prefix nicks if you\n"
" want to ignore someone `/ignore add re:[~@%]{0,3}nightbot` should ignore\n"
" a nick with all or none of the prefixes used by this script.\n"
" NOTE: This may cause high cpu usage in very active chat and/or on slower cpus.\n"
" This can also be disabled by setting\n /set plugins.var.python.twitch.prefix_nicks off\n"
"\n\n"
" If you are experiencing errors you can enable debug mode by setting\n"
" /set plugins.var.python.twitch.debug on\n"
"\n\n"
" Required server settings:\n"
" /server add twitch irc.twitch.tv\n"
" /set irc.server.twitch.capabilities \"twitch.tv/membership,twitch.tv/commands,twitch.tv/tags\"\n"
Loading
Loading
Loading
Loading
@@ -26,7 +26,7 @@ import re
 
SCRIPT_NAME = 'unhighlight'
SCRIPT_AUTHOR = 'xiagu'
SCRIPT_VERSION = '0.1.0'
SCRIPT_VERSION = '0.1.1'
SCRIPT_LICENSE = 'GPL3'
SCRIPT_DESC = 'Allows per-buffer specification of a regex that prevents highlights.'
 
Loading
Loading
@@ -93,7 +93,7 @@ Examples:
Unhighlight SASL authentication messages for double logins:
/buffer weechat
/buffer set localvar_set_unhighlight_regex SaslServ
/autosetbuffer add core.weechat localvar_set_unhighlight_regex SaslServ
/buffer_autoset add core.weechat localvar_set_unhighlight_regex SaslServ
List buffers with autoset unhighlights:
/{script_name} list
Show this help:
Loading
Loading
Loading
Loading
@@ -24,6 +24,7 @@ import tempfile
import time
import calendar
import socket
import getpass
 
# This twitter plugin can be extended even more. Just look at the twitter api
# doc here: https://dev.twitter.com/docs/api/1.1
Loading
Loading
@@ -119,7 +120,7 @@ desc_dict = dict(
"of the user that you reply to in the tweet text. If this is not " +
"the case this will be treated like a normal tweet instead.",
new_tweets="Get new tweets from your home_timeline. This is only " +
"useful if you have disabled the auto updater",
"useful if you have disconnected from the home twitter stream",
follow_user="<user>, Add user to people you follow",
unfollow_user="<user>, Remove user for people you follow",
following="[|<id>|<user>|<user> <id>], Show 'friends' of <user> or " +
Loading
Loading
@@ -337,6 +338,12 @@ def stream_message(buffer,tweet):
#TODO make the event printing better
weechat.prnt_date_tags(buffer, 0, "no_highlight", "%s%s" % (weechat.prefix("network"),
tweet['source']['screen_name'] + " " + event_str + " " + tweet['target']['screen_name'] + extra_str))
elif 'friends' in tweet:
#This should be the initital message you get listing friend ids when connecting to the twitter stream
weechat.prnt(buffer, "%s%s" % (weechat.prefix("network"), "Connected to twitter streaming API."))
#Get new tweets since the last update (we might have missed some if this is after a reconnect)
#Get latest tweets from timeline
my_command_cb("silent", buffer, "new")
else:
weechat.prnt(buffer, "%s%s" % (weechat.prefix("network"),
"recv stream data: " + str(tweet)))
Loading
Loading
@@ -344,7 +351,7 @@ def stream_message(buffer,tweet):
def twitter_stream_cb(buffer,fd):
 
#accept connection
server = sock_fd_dict[sock_fd_dict[fd]]
server = sock_fd_dict[ sock_fd_dict[str(fd)] ]
conn, addr = server.accept()
tweet = ""
data = True
Loading
Loading
@@ -371,7 +378,7 @@ def twitter_stream_cb(buffer,fd):
#We need to send over the stream options
 
options = dict(screen_name = script_options['screen_name'],
name = sock_fd_dict[fd],
name = sock_fd_dict[str(fd)],
alt_rt_style = int(script_options['alt_rt_style']),
home_replies = int(script_options['home_replies']),
token = script_options["oauth_token"],
Loading
Loading
@@ -442,10 +449,11 @@ def twitter_stream(cmd_args):
# configuration. So it's defined here if the defaults change.
stream_options = dict( timeout=None, block=True, heartbeat_timeout=90 )
 
# Reconnect timer, when zero it will not try to reconnect
re_timer = 1
# Reconnect timer list [1sec, 5sec, 10sec, 1min, 2min]
re_timer = [1,2,10,60,120]
re_timer_idx = 0
 
while re_timer:
while True:
try:
if name == "twitter":
#home timeline stream
Loading
Loading
@@ -504,8 +512,8 @@ def twitter_stream(cmd_args):
client.sendall(bytes(str(tweet),"utf-8"))
client.close()
stream_end_message = "Text message"
# Reset the reconnect timer when we get a new message
re_timer = 1
# Reset the reconnect timer index when we get a new message
re_timer_idx = 0
else:
#Got a other type of message
client = connect()
Loading
Loading
@@ -514,14 +522,12 @@ def twitter_stream(cmd_args):
stream_end_message = "Unhandled type message"
 
client = connect()
client.sendall(bytes('"Disconnected, trying to reconnect."',"utf-8"))
client.sendall(bytes('"Disconnected, trying to reconnect in {0} sec. Reason: {1}"'.format(re_timer[re_timer_idx], stream_end_message),"utf-8"))
client.close()
 
if re_timer > 5:
re_timer = 0
else:
time.sleep(re_timer)
re_timer += 4
time.sleep(re_timer[re_timer_idx])
if re_timer_idx < (len(re_timer) - 1):
re_timer_idx += 1
 
return "Stream shut down after: " + stream_end_message + ". You'll have to restart the stream manually. (:re_home, if home stream)"
 
Loading
Loading
@@ -558,7 +564,7 @@ def create_stream(name, args = ""):
setup_buffer(buffer)
 
if not sock_fd_dict.get(name):
file_name = tempfile.gettempdir() + "/we_tw_" + name
file_name = tempfile.gettempdir() + "/we_tw_" + getpass.getuser() + "_" + name
if os.path.exists(file_name):
os.remove(file_name)
 
Loading
Loading
@@ -1161,8 +1167,6 @@ def oauth_proc_cb(data, command, rc, out, err):
 
for nick in process_output:
add_to_nicklist(buffer,nick)
#Get latest tweets from timeline
my_command_cb("silent", buffer, "new")
elif data == "auth1":
#First auth step to request pin code
oauth_token, oauth_token_secret = parse_oauth_tokens(out)
Loading
Loading
@@ -1237,13 +1241,13 @@ def finish_init():
return
setup_buffer(buffer)
 
#Add friends to nick list and print new tweets
#Add friends to nick list
weechat.hook_process("python3 " + SCRIPT_FILE_PATH + " " +
script_options["oauth_token"] + " " + script_options["oauth_secret"] + " " +
"f " + script_options['screen_name'] + " []", 10 * 1000, "oauth_proc_cb", "friends")
 
if __name__ == "__main__" and weechat_call:
weechat.register( SCRIPT_NAME , "DarkDefender", "1.2.6", "GPL3", "Weechat twitter client", "", "")
weechat.register( SCRIPT_NAME , "DarkDefender", "1.2.7", "GPL3", "Weechat twitter client", "", "")
 
if not import_ok:
weechat.prnt("", "Can't load twitter python lib >= " + required_twitter_version)
Loading
Loading
@@ -1251,7 +1255,7 @@ if __name__ == "__main__" and weechat_call:
else:
hook_commands_and_completions()
 
# Set register script options if not available
#Set register script options if not available
 
for option, default_value in script_options.items():
if not weechat.config_is_set_plugin(option):
Loading
Loading
@@ -1263,11 +1267,10 @@ if __name__ == "__main__" and weechat_call:
weechat.config_set_plugin(option, default_value)
 
read_config()
# hook for config changes
#Hook for config changes
weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "")
 
# create buffer
#Create buffer
twit_buf = weechat.buffer_new("twitter", "buffer_input_cb", "", "buffer_close_cb", "")
 
#Hook text input so we can update the bar item
Loading
Loading
@@ -1275,7 +1278,8 @@ if __name__ == "__main__" and weechat_call:
 
if script_options['auth_complete']:
finish_init()
#create home_timeline stream
#Create home_timeline stream.
#This will indirectly trigger the ":new" command if stream sucessfully starts
create_stream("twitter")
else:
weechat.prnt(twit_buf,"""You have to register this plugin with twitter for it to work.
Loading
Loading
# coding: utf-8
# -*- coding: utf-8 -*-
#
# Copyright (c) 2014 Kengo Tateishi <embrace.ddd.flake.peace@gmail.com>
# https://github.com/tkengo/weechat-url-hinter
Loading
Loading
@@ -35,7 +35,7 @@ require 'singleton'
# Register url-hinter plugin to weechat and do initialization.
#
def weechat_init
Weechat.register('url_hinter', 'Kengo Tateish', '0.4', 'GPL3', 'Open an url in the weechat buffer to type a hint', '', '')
Weechat.register('url_hinter', 'Kengo Tateish', '0.41', 'GPL3', 'Open an url in the weechat buffer to type a hint', '', '')
Weechat.hook_command(
'url_hinter',
'Search url strings, and highlight them, and if you type a hint key, open the url related to hint key.',
Loading
Loading
@@ -192,7 +192,7 @@ class Hint
private
 
def get_hint_keys
option = 'hintkeys'
option = 'hintkeys'
if Weechat.config_is_set_plugin(option) == 0
Weechat.config_set_plugin(option, 'jfhkgyuiopqwertnmzxcvblasd')
end
Loading
Loading
@@ -350,7 +350,9 @@ class Line
end
 
def remove_color_message
Weechat.string_remove_color(message.dup, '')
ret = Weechat.string_remove_color(message.dup, '')
ret.force_encoding("UTF-8")
return ret
end
 
def next
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment