remove unused scripts

master
Ben Harris 2019-06-25 10:18:27 -04:00
parent d3246bcc2a
commit 2370dab7d5
12 changed files with 80 additions and 2987 deletions

View File

@ -714,7 +714,7 @@ darenet.local_hostname
darenet.usermode darenet.usermode
darenet.command darenet.command
darenet.command_delay darenet.command_delay
darenet.autojoin = "#DareNET,#chat,#bitbot" darenet.autojoin = "#bitbot,#DareNET,#chat ,44"
darenet.autorejoin darenet.autorejoin
darenet.autorejoin_delay darenet.autorejoin_delay
darenet.connection_timeout darenet.connection_timeout

View File

@ -1,6 +1,6 @@
# #
# highmon.pl - Highlight Monitoring for weechat 0.3.0 # highmon.pl - Highlight Monitoring for weechat 0.3.0
# Version 2.5 # Version 2.6
# #
# Add 'Highlight Monitor' buffer/bar to log all highlights in one spot # Add 'Highlight Monitor' buffer/bar to log all highlights in one spot
# #
@ -73,6 +73,8 @@
# Bugs and feature requests at: https://github.com/KenjiE20/highmon # Bugs and feature requests at: https://github.com/KenjiE20/highmon
# History: # History:
# 2019-05-13, HubbeKing <hubbe128@gmail.com>
# v2.6: -add: send "logger_backlog" signal on buffer open if logging is enabled
# 2014-08-16, KenjiE20 <longbow@longbowslair.co.uk>: # 2014-08-16, KenjiE20 <longbow@longbowslair.co.uk>:
# v2.5: -add: clearbar command to clear bar output # v2.5: -add: clearbar command to clear bar output
# -add: firstrun output prompt to check the help text for set up hints as they were being missed # -add: firstrun output prompt to check the help text for set up hints as they were being missed
@ -306,7 +308,7 @@ sub highmon_buffer_open
# Turn off notify, highlights # Turn off notify, highlights
if ($highmon_buffer ne "") if ($highmon_buffer ne "")
{ {
if (weechat::config_get_plugin("hotlist_show" eq "off")) if (weechat::config_get_plugin("hotlist_show") eq "off")
{ {
weechat::buffer_set($highmon_buffer, "notify", "0"); weechat::buffer_set($highmon_buffer, "notify", "0");
} }
@ -317,6 +319,11 @@ sub highmon_buffer_open
{ {
weechat::buffer_set($highmon_buffer, "localvar_set_no_log", "1"); weechat::buffer_set($highmon_buffer, "localvar_set_no_log", "1");
} }
# send "logger_backlog" signal if logging is enabled to display backlog
if (weechat::config_get_plugin("logging") eq "on")
{
weechat::hook_signal_send("logger_backlog", weechat::WEECHAT_HOOK_SIGNAL_POINTER, $highmon_buffer)
}
} }
return weechat::WEECHAT_RC_OK; return weechat::WEECHAT_RC_OK;
} }
@ -1124,7 +1131,7 @@ sub format_buffer_name
} }
# Check result of register, and attempt to behave in a sane manner # Check result of register, and attempt to behave in a sane manner
if (!weechat::register("highmon", "KenjiE20", "2.5", "GPL3", "Highlight Monitor", "", "")) if (!weechat::register("highmon", "KenjiE20", "2.6", "GPL3", "Highlight Monitor", "", ""))
{ {
# Double load # Double load
weechat::print ("", "\tHighmon is already loaded"); weechat::print ("", "\tHighmon is already loaded");

View File

@ -1,472 +0,0 @@
# -*- coding: utf-8 -*-
#
# anotify.py
# Copyright (c) 2012 magnific0 <jacco.geul@gmail.com>
#
# based on:
# growl.py
# Copyright (c) 2011 Sorin Ionescu <sorin.ionescu@gmail.com>
#
# 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 NONINFRINGEMENT. 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 = 'anotify'
SCRIPT_AUTHOR = 'magnific0'
SCRIPT_VERSION = '1.0.1'
SCRIPT_LICENSE = 'MIT'
SCRIPT_DESC = 'Sends libnotify notifications upon events.'
# Changelog
# 2014-05-10: v1.0.1 Change hook_print callback argument type of
# displayed/highlight (WeeChat >= 1.0)
# 2012-09-20: v1.0.0 Forked from original and adapted for libnotify.
# -----------------------------------------------------------------------------
# Settings
# -----------------------------------------------------------------------------
SETTINGS = {
'show_public_message': 'off',
'show_private_message': 'on',
'show_public_action_message': 'off',
'show_private_action_message': 'on',
'show_notice_message': 'off',
'show_invite_message': 'on',
'show_highlighted_message': 'on',
'show_server': 'on',
'show_channel_topic': 'on',
'show_dcc': 'on',
'show_upgrade_ended': 'on',
'sticky': 'off',
'sticky_away': 'on',
'icon': '/usr/share/pixmaps/weechat.xpm',
}
# -----------------------------------------------------------------------------
# Imports
# -----------------------------------------------------------------------------
try:
import re
import os
import weechat
import pynotify
IMPORT_OK = True
except ImportError as error:
IMPORT_OK = False
if str(error).find('weechat') != -1:
print('This script must be run under WeeChat.')
print('Get WeeChat at http://www.weechat.org.')
else:
weechat.prnt('', 'anotify: {0}'.format(error))
# -----------------------------------------------------------------------------
# Globals
# -----------------------------------------------------------------------------
TAGGED_MESSAGES = {
'public message or action': set(['irc_privmsg', 'notify_message']),
'private message or action': set(['irc_privmsg', 'notify_private']),
'notice message': set(['irc_notice', 'notify_private']),
'invite message': set(['irc_invite', 'notify_highlight']),
'channel topic': set(['irc_topic', ]),
#'away status': set(['away_info', ]),
}
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),
'dcc chat closed':
re.compile(r'^xfer: chat closed with (\w+)', re.UNICODE),
'dcc get request':
re.compile(
r'^xfer: incoming file from (\w+) [^:]+: ((?:,\w|[^,])+),',
re.UNICODE),
'dcc get completed':
re.compile(r'^xfer: file ([^\s]+) received from \w+: OK', re.UNICODE),
'dcc get failed':
re.compile(
r'^xfer: file ([^\s]+) received from \w+: FAILED',
re.UNICODE),
'dcc send completed':
re.compile(r'^xfer: file ([^\s]+) sent to \w+: OK', re.UNICODE),
'dcc send failed':
re.compile(r'^xfer: file ([^\s]+) sent to \w+: FAILED', re.UNICODE),
}
DISPATCH_TABLE = {
'away status': 'set_away_status',
'public message or action': 'notify_public_message_or_action',
'private message or action': 'notify_private_message_or_action',
'notice message': 'notify_notice_message',
'invite message': 'notify_invite_message',
'channel topic': 'notify_channel_topic',
'dcc chat request': 'notify_dcc_chat_request',
'dcc chat closed': 'notify_dcc_chat_closed',
'dcc get request': 'notify_dcc_get_request',
'dcc get completed': 'notify_dcc_get_completed',
'dcc get failed': 'notify_dcc_get_failed',
'dcc send completed': 'notify_dcc_send_completed',
'dcc send failed': 'notify_dcc_send_failed',
}
STATE = {
'icon': None,
'is_away': False
}
# -----------------------------------------------------------------------------
# Notifiers
# -----------------------------------------------------------------------------
def cb_irc_server_connected(data, signal, signal_data):
'''Notify when connected to IRC server.'''
if weechat.config_get_plugin('show_server') == 'on':
a_notify(
'Server',
'Server Connected',
'Connected to network {0}.'.format(signal_data))
return weechat.WEECHAT_RC_OK
def cb_irc_server_disconnected(data, signal, signal_data):
'''Notify when disconnected to IRC server.'''
if weechat.config_get_plugin('show_server') == 'on':
a_notify(
'Server',
'Server Disconnected',
'Disconnected from network {0}.'.format(signal_data))
return weechat.WEECHAT_RC_OK
def cb_notify_upgrade_ended(data, signal, signal_data):
'''Notify on end of WeeChat upgrade.'''
if weechat.config_get_plugin('show_upgrade_ended') == 'on':
a_notify(
'WeeChat',
'WeeChat Upgraded',
'WeeChat has been upgraded.')
return weechat.WEECHAT_RC_OK
def notify_highlighted_message(prefix, message):
'''Notify on highlighted message.'''
if weechat.config_get_plugin("show_highlighted_message") == "on":
a_notify(
'Highlight',
'Highlighted Message',
"{0}: {1}".format(prefix, message),
priority=pynotify.URGENCY_CRITICAL)
def notify_public_message_or_action(prefix, message, highlighted):
'''Notify on public message or action.'''
if prefix == ' *':
regex = re.compile(r'^(\w+) (.+)$', re.UNICODE)
match = regex.match(message)
if match:
prefix = match.group(1)
message = match.group(2)
notify_public_action_message(prefix, message, highlighted)
else:
if highlighted:
notify_highlighted_message(prefix, message)
elif weechat.config_get_plugin("show_public_message") == "on":
a_notify(
'Public',
'Public Message',
'{0}: {1}'.format(prefix, message))
def notify_private_message_or_action(prefix, message, highlighted):
'''Notify on private message or action.'''
regex = re.compile(r'^CTCP_MESSAGE.+?ACTION (.+)$', re.UNICODE)
match = regex.match(message)
if match:
notify_private_action_message(prefix, match.group(1), highlighted)
else:
if prefix == ' *':
regex = re.compile(r'^(\w+) (.+)$', re.UNICODE)
match = regex.match(message)
if match:
prefix = match.group(1)
message = match.group(2)
notify_private_action_message(prefix, message, highlighted)
else:
if highlighted:
notify_highlighted_message(prefix, message)
elif weechat.config_get_plugin("show_private_message") == "on":
a_notify(
'Private',
'Private Message',
'{0}: {1}'.format(prefix, message))
def notify_public_action_message(prefix, message, highlighted):
'''Notify on public action message.'''
if highlighted:
notify_highlighted_message(prefix, message)
elif weechat.config_get_plugin("show_public_action_message") == "on":
a_notify(
'Action',
'Public Action Message',
'{0}: {1}'.format(prefix, message),
priority=pynotify.URGENCY_NORMAL)
def notify_private_action_message(prefix, message, highlighted):
'''Notify on private action message.'''
if highlighted:
notify_highlighted_message(prefix, message)
elif weechat.config_get_plugin("show_private_action_message") == "on":
a_notify(
'Action',
'Private Action Message',
'{0}: {1}'.format(prefix, message),
priority=pynotify.URGENCY_NORMAL)
def notify_notice_message(prefix, message, highlighted):
'''Notify on notice message.'''
regex = re.compile(r'^([^\s]*) [^:]*: (.+)$', re.UNICODE)
match = regex.match(message)
if match:
prefix = match.group(1)
message = match.group(2)
if highlighted:
notify_highlighted_message(prefix, message)
elif weechat.config_get_plugin("show_notice_message") == "on":
a_notify(
'Notice',
'Notice Message',
'{0}: {1}'.format(prefix, message))
def notify_invite_message(prefix, message, highlighted):
'''Notify on channel invitation message.'''
if weechat.config_get_plugin("show_invite_message") == "on":
regex = re.compile(
r'^You have been invited to ([^\s]+) by ([^\s]+)$', re.UNICODE)
match = regex.match(message)
if match:
channel = match.group(1)
nick = match.group(2)
a_notify(
'Invite',
'Channel Invitation',
'{0} has invited you to join {1}.'.format(nick, channel))
def notify_channel_topic(prefix, message, highlighted):
'''Notify on channel topic change.'''
if weechat.config_get_plugin("show_channel_topic") == "on":
regex = re.compile(
r'^\w+ has (?:changed|unset) topic for ([^\s]+)' +
'(?:(?: from "(?:(?:"\w|[^"])+)")? to "((?:"\w|[^"])+)")?',
re.UNICODE)
match = regex.match(message)
if match:
channel = match.group(1)
topic = match.group(2) or ''
a_notify(
'Channel',
'Channel Topic',
"{0}: {1}".format(channel, topic))
def notify_dcc_chat_request(match):
'''Notify on DCC chat request.'''
if weechat.config_get_plugin("show_dcc") == "on":
nick = match.group(1)
a_notify(
'DCC',
'Direct Chat Request',
'{0} wants to chat directly.'.format(nick))
def notify_dcc_chat_closed(match):
'''Notify on DCC chat termination.'''
if weechat.config_get_plugin("show_dcc") == "on":
nick = match.group(1)
a_notify(
'DCC',
'Direct Chat Ended',
'Direct chat with {0} has ended.'.format(nick))
def notify_dcc_get_request(match):
'Notify on DCC get request.'
if weechat.config_get_plugin("show_dcc") == "on":
nick = match.group(1)
file_name = match.group(2)
a_notify(
'DCC',
'File Transfer Request',
'{0} wants to send you {1}.'.format(nick, file_name))
def notify_dcc_get_completed(match):
'Notify on DCC get completion.'
if weechat.config_get_plugin("show_dcc") == "on":
file_name = match.group(1)
a_notify('DCC', 'Download Complete', file_name)
def notify_dcc_get_failed(match):
'Notify on DCC get failure.'
if weechat.config_get_plugin("show_dcc") == "on":
file_name = match.group(1)
a_notify('DCC', 'Download Failed', file_name)
def notify_dcc_send_completed(match):
'Notify on DCC send completion.'
if weechat.config_get_plugin("show_dcc") == "on":
file_name = match.group(1)
a_notify('DCC', 'Upload Complete', file_name)
def notify_dcc_send_failed(match):
'Notify on DCC send failure.'
if weechat.config_get_plugin("show_dcc") == "on":
file_name = match.group(1)
a_notify('DCC', 'Upload Failed', file_name)
# -----------------------------------------------------------------------------
# Utility
# -----------------------------------------------------------------------------
def set_away_status(match):
status = match.group(1)
if status == 'been ':
STATE['is_away'] = True
if status == 'longer ':
STATE['is_away'] = False
def cb_process_message(
data,
wbuffer,
date,
tags,
displayed,
highlight,
prefix,
message
):
'''Delegates incoming messages to appropriate handlers.'''
tags = set(tags.split(','))
functions = globals()
is_public_message = tags.issuperset(
TAGGED_MESSAGES['public message or action'])
buffer_name = weechat.buffer_get_string(wbuffer, 'name')
dcc_buffer_regex = re.compile(r'^irc_dcc\.', re.UNICODE)
dcc_buffer_match = dcc_buffer_regex.match(buffer_name)
highlighted = False
if int(highlight):
highlighted = True
# Private DCC message identifies itself as public.
if is_public_message and dcc_buffer_match:
notify_private_message_or_action(prefix, message, highlighted)
return weechat.WEECHAT_RC_OK
# Pass identified, untagged message to its designated function.
for key, value in UNTAGGED_MESSAGES.items():
match = value.match(message)
if match:
functions[DISPATCH_TABLE[key]](match)
return weechat.WEECHAT_RC_OK
# Pass identified, tagged message to its designated function.
for key, value in TAGGED_MESSAGES.items():
if tags.issuperset(value):
functions[DISPATCH_TABLE[key]](prefix, message, highlighted)
return weechat.WEECHAT_RC_OK
return weechat.WEECHAT_RC_OK
def a_notify(notification, title, description, priority=pynotify.URGENCY_LOW):
'''Returns whether notifications should be sticky.'''
is_away = STATE['is_away']
icon = STATE['icon']
time_out = 5000
if weechat.config_get_plugin('sticky') == 'on':
time_out = 0
if weechat.config_get_plugin('sticky_away') == 'on' and is_away:
time_out = 0
try:
pynotify.init("wee-notifier")
wn = pynotify.Notification(title, description, icon)
wn.set_urgency(priority)
wn.set_timeout(time_out)
wn.show()
except Exception as error:
weechat.prnt('', 'anotify: {0}'.format(error))
# -----------------------------------------------------------------------------
# Main
# -----------------------------------------------------------------------------
def main():
'''Sets up WeeChat notifications.'''
# Initialize options.
for option, value in SETTINGS.items():
if not weechat.config_is_set_plugin(option):
weechat.config_set_plugin(option, value)
# Initialize.
name = "WeeChat"
icon = "/usr/share/pixmaps/weechat.xpm"
notifications = [
'Public',
'Private',
'Action',
'Notice',
'Invite',
'Highlight',
'Server',
'Channel',
'DCC',
'WeeChat'
]
STATE['icon'] = icon
# Register hooks.
weechat.hook_signal(
'irc_server_connected',
'cb_irc_server_connected',
'')
weechat.hook_signal(
'irc_server_disconnected',
'cb_irc_server_disconnected',
'')
weechat.hook_signal('upgrade_ended', 'cb_upgrade_ended', '')
weechat.hook_print('', '', '', 1, 'cb_process_message', '')
if __name__ == '__main__' and IMPORT_OK and weechat.register(
SCRIPT_NAME,
SCRIPT_AUTHOR,
SCRIPT_VERSION,
SCRIPT_LICENSE,
SCRIPT_DESC,
'',
''
):
main()

View File

@ -1 +0,0 @@
../anotify.py

View File

@ -1 +0,0 @@
../autosavekey.py

View File

@ -1 +0,0 @@
../otr.py

View File

@ -1,263 +0,0 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2013-2018 by nils_2 <weechatter@arcor.de>
#
# save channel key from protected channel(s) to autojoin or secure data
#
# 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/>.
#
# idea by freenode.elsae
#
# 2018-05-11: nils_2, (freenode.#weechat)
# 0.4 : make script python3 compatible
# : add /help text
#
# 2015-05-09: nils_2, (freenode.#weechat)
# 0.3 : fix: ValueError (reported by: Darpa)
#
# 2014-12-20: nils_2, (freenode.#weechat)
# 0.2 : add option "add" to automatically add channel/key to autojoin option after a /join (idea by Prezident)
#
# 2013-10-03: nils_2, (freenode.#weechat)
# 0.1 : initial release
#
# requires: WeeChat version 0.3.2
#
# Development is currently hosted at
# https://github.com/weechatter/weechat-scripts
try:
import weechat,re
except Exception:
print("This script must be run under WeeChat.")
print("Get WeeChat now at: http://www.weechat.org/")
quit()
SCRIPT_NAME = "autosavekey"
SCRIPT_AUTHOR = "nils_2 <weechatter@arcor.de>"
SCRIPT_VERSION = "0.4"
SCRIPT_LICENSE = "GPL"
SCRIPT_DESC = "save channel key from protected channel(s) to autojoin option or secure data"
OPTIONS = { 'mute' : ('off','execute command silently, only error messages will be displayed.'),
'secure' : ('off','change channel key in secure data.'),
'add' : ('off','adds channel and key to autojoin list on /join, if channel/key does not already exists'),
}
# /join #channel key
# signal = freenode,irc_raw_in_324
# signal_data = :asimov.freenode.net 324 nick #channel +modes key
def irc_raw_in_324_cb(data, signal, signal_data):
parsed = get_hashtable(signal_data)
server = signal.split(',',1)[0]
argv = parsed['arguments'].split(" ")
# buffer without channel key
if len(argv) < 4:
return weechat.WEECHAT_RC_OK
channel = argv[1]
new_key = argv[3]
autojoin_list = get_autojoin(server)
if not autojoin_list:
return weechat.WEECHAT_RC_OK
# check autojoin for space
if len(re.findall(r" ", autojoin_list)) > 1:
weechat.prnt('', '%s%s: autojoin format for server "%s" invalid (two or more spaces).' % (weechat.prefix('error'),SCRIPT_NAME,server) )
return weechat.WEECHAT_RC_OK
# no keylist, only channels in autojoin option
if len(re.findall(r" ", autojoin_list)) == 0:
argv_channels = autojoin_list.split(',')
argv_keys = []
else:
# split autojoin option to a channel and a key list
arg_channel,arg_keys = autojoin_list.split(' ')
argv_channels = arg_channel.split(',')
argv_keys = arg_keys.split(',')
# check channel position
try:
channel_position = argv_channels.index(channel)
except ValueError:
channel_position = -1
sec_data = 0
# does buffer already exist in autojoin list?
if channel_position >= 0:
# remove channel from list
argv_channels.pop(channel_position)
# check if there is at least one key in list
if len(argv_keys) >= 1:
# check channel position and number of keys
if channel_position <= len(argv_keys):
# remove key from list
sec_data = check_key_for_secure(argv_keys,channel_position)
sec_data_name = argv_keys[channel_position][11:-1]
argv_keys.pop(channel_position)
else:
if OPTIONS['add'].lower() == 'off':
return weechat.WEECHAT_RC_OK
# add channel and key at first position
argv_channels.insert(0, channel)
argv_keys.insert(0,new_key)
# check weechat version and if secure option is on and secure data will be used for this key?
if int(version) >= 0x00040200 and OPTIONS['secure'].lower() == 'on' and sec_data == 1:
weechat.command('','%s/secure set %s %s' % (use_mute(),sec_data_name,new_key))
else:
if sec_data == 1:
weechat.prnt('', '%s%s: key for channel "%s.%s" not changed! option "plugins.var.python.%s.secure" is off and you are using secured data for key.' % (weechat.prefix('error'),SCRIPT_NAME,server,channel,SCRIPT_NAME) )
return weechat.WEECHAT_RC_OK
new_joined_option = '%s %s' % (','.join(argv_channels),','.join(argv_keys))
save_autojoin_option(server,new_joined_option)
return weechat.WEECHAT_RC_OK
# replace an already existing channel key with an new one
# when OP changes channel key
def irc_raw_in_mode_cb(data, signal, signal_data):
parsed = get_hashtable(signal_data)
server = signal.split(',',1)[0]
argv = parsed['arguments'].split(" ")
if argv[1] != "+k":
return weechat.WEECHAT_RC_OK
channel = argv[0]
new_key = argv[2]
add_key_to_list(server,channel,new_key)
return weechat.WEECHAT_RC_OK
def add_key_to_list(server,channel,new_key):
autojoin_list = get_autojoin(server)
if not autojoin_list:
return weechat.WEECHAT_RC_OK
# check autojoin for space
if len(re.findall(r" ", autojoin_list)) == 0:
weechat.prnt('', '%s%s: no password(s) set in autojoin for server "%s".' % (weechat.prefix('error'),SCRIPT_NAME,server) )
return weechat.WEECHAT_RC_OK
if len(re.findall(r" ", autojoin_list)) > 1:
weechat.prnt('', '%s%s: autojoin format for server "%s" invalid (two or more spaces).' % (weechat.prefix('error'),SCRIPT_NAME,server) )
return weechat.WEECHAT_RC_OK
# split autojoin option to a channel and a key list
arg_channel,arg_keys = autojoin_list.split(' ')
argv_channels = arg_channel.split(',')
argv_keys = arg_keys.split(',')
# search for channel name in list of channels and get position
if channel in argv_channels:
channel_pos_in_list = argv_channels.index(channel)
# enough keys in list? list counts from 0!
if channel_pos_in_list + 1 > len(argv_keys):
weechat.prnt('', '%s%s: not enough keys in list or channel position is not valid. check out autojoin option for server "%s".' % (weechat.prefix('error'),SCRIPT_NAME,server) )
return weechat.WEECHAT_RC_OK
sec_data = check_key_for_secure(argv_keys,channel_pos_in_list)
# check weechat version and if secure option is on and secure data will be used for this key?
if int(version) >= 0x00040200 and OPTIONS['secure'].lower() == 'on' and sec_data == 1:
sec_data_name = argv_keys[channel_pos_in_list][11:-1]
weechat.command('','%s/secure set %s %s' % (use_mute(),sec_data_name,new_key))
else:
if sec_data == 1:
weechat.prnt('', '%s%s: key for channel "%s.%s" not changed! option "plugins.var.python.%s.secure" is off and you are using secured data for key.' % (weechat.prefix('error'),SCRIPT_NAME,server,channel,SCRIPT_NAME) )
return weechat.WEECHAT_RC_OK
argv_keys[channel_pos_in_list] = new_key
new_joined_option = '%s %s' % (','.join(argv_channels),','.join(argv_keys))
save_autojoin_option(server,new_joined_option)
return weechat.WEECHAT_RC_OK
def get_hashtable(string):
parsed = weechat.info_get_hashtable('irc_message_parse', dict(message=string))
try:
parsed['message'] = parsed['arguments'].split(' :', 1)[1]
except:
parsed['message'] = ""
return parsed
def get_autojoin(server):
return weechat.config_string(weechat.config_get('irc.server.%s.autojoin' % server))
def find_element_in_list(element,list_element):
try:
index_element=list_element.index(element)
return index_element
except ValueError:
return -1
def save_autojoin_option(server,new_joined_option):
weechat.command('','%s/set irc.server.%s.autojoin %s' % (use_mute(),server,new_joined_option))
def use_mute():
use_mute = ''
if OPTIONS['mute'].lower() == 'on':
use_mute = '/mute '
return use_mute
# check key for "${sec.data."
def check_key_for_secure(argv_keys,position):
sec_data = 0
if argv_keys[position][0:11] == '${sec.data.':
sec_data = 1
return sec_data
def cmd_autosavekey(data, buffer, args):
weechat.command('', '/help %s' % SCRIPT_NAME)
return weechat.WEECHAT_RC_OK
# ================================[ weechat options & description ]===============================
def init_options():
for option,value in OPTIONS.items():
if not weechat.config_is_set_plugin(option):
weechat.config_set_plugin(option, value[0])
OPTIONS[option] = value[0]
else:
OPTIONS[option] = weechat.config_get_plugin(option)
weechat.config_set_desc_plugin(option, '%s (default: "%s")' % (value[1], value[0]))
def toggle_refresh(pointer, name, value):
global OPTIONS
option = name[len('plugins.var.python.' + SCRIPT_NAME + '.'):] # get optionname
OPTIONS[option] = value # save new value
return weechat.WEECHAT_RC_OK
# ================================[ main ]===============================
if __name__ == "__main__":
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''):
weechat.hook_command(SCRIPT_NAME,SCRIPT_DESC,
'',
'You have to edit options with: /set *autosavekey*\n'
'I suggest using /iset script or /fset plugin.\n',
'',
'cmd_autosavekey',
'')
version = weechat.info_get("version_number", "") or 0
if int(version) >= 0x00030200:
init_options()
weechat.hook_config( 'plugins.var.python.' + SCRIPT_NAME + '.*', 'toggle_refresh', '' )
weechat.hook_signal("*,irc_raw_in_mode","irc_raw_in_mode_cb","")
weechat.hook_signal("*,irc_raw_in_324","irc_raw_in_324_cb","")
else:
weechat.prnt("","%s%s %s" % (weechat.prefix("error"),SCRIPT_NAME,": needs version 0.3.2 or higher"))
weechat.command("","/wait 1ms /python unload %s" % SCRIPT_NAME)

View File

@ -25,6 +25,10 @@
# #
# Changelog: # Changelog:
# 3.6:
# * Add more documentation on provided info hooks.
# 3.5:
# * Add ${info:autosort_escape,...} to escape arguments for other info hooks.
# 3.4: # 3.4:
# * Fix rate-limit of sorting to prevent high CPU load and lock-ups. # * Fix rate-limit of sorting to prevent high CPU load and lock-ups.
# * Fix bug in parsing empty arguments for info hooks. # * Fix bug in parsing empty arguments for info hooks.
@ -76,7 +80,7 @@ import weechat
SCRIPT_NAME = 'autosort' SCRIPT_NAME = 'autosort'
SCRIPT_AUTHOR = 'Maarten de Vries <maarten@de-vri.es>' SCRIPT_AUTHOR = 'Maarten de Vries <maarten@de-vri.es>'
SCRIPT_VERSION = '3.4' SCRIPT_VERSION = '3.6'
SCRIPT_LICENSE = 'GPL3' SCRIPT_LICENSE = 'GPL3'
SCRIPT_DESC = 'Flexible automatic (or manual) buffer sorting based on eval expressions.' SCRIPT_DESC = 'Flexible automatic (or manual) buffer sorting based on eval expressions.'
@ -184,7 +188,7 @@ class Config:
'irc_last': '${if:${buffer.plugin.name}==irc}', 'irc_last': '${if:${buffer.plugin.name}==irc}',
'irc_raw_first': '${if:${buffer.full_name}!=irc.irc_raw}', 'irc_raw_first': '${if:${buffer.full_name}!=irc.irc_raw}',
'irc_raw_last': '${if:${buffer.full_name}==irc.irc_raw}', 'irc_raw_last': '${if:${buffer.full_name}==irc.irc_raw}',
'hashless_name': '${info:autosort_replace,#,,${buffer.name}}', 'hashless_name': '${info:autosort_replace,#,,${info:autosort_escape,${buffer.name}}}',
}) })
default_signal_delay = 5 default_signal_delay = 5
@ -746,6 +750,17 @@ def parse_args(args, max = None):
if args is None: break if args is None: break
return result, args return result, args
def on_info_escape(pointer, name, arguments):
result = ''
for c in arguments:
if c == '\\':
result += '\\\\'
elif c == ',':
result += '\\,'
else:
result +=c
return result
def on_info_replace(pointer, name, arguments): def on_info_replace(pointer, name, arguments):
arguments, rest = parse_args(arguments, 3) arguments, rest = parse_args(arguments, 3)
if rest or len(arguments) < 3: if rest or len(arguments) < 3:
@ -910,6 +925,36 @@ Rename a helper variable.
Swap the expressions of two helper variables in the list. Swap the expressions of two helper variables in the list.
{*white}# Info hooks{reset}
Autosort comes with a number of info hooks to add some extra functionality to regular weechat eval strings.
Info hooks can be used in eval strings in the form of {cyan}${{info:some_hook,arguments}}{reset}.
Commas and backslashes in arguments to autosort info hooks (except for {cyan}${{info:autosort_escape}}{reset}) must be escaped with a backslash.
{*white}${{info:{brown}autosort_replace{white},{cyan}pattern{white},{cyan}replacement{white},{cyan}source{white}}}{reset}
Replace all occurrences of {cyan}pattern{reset} with {cyan}replacement{reset} in the string {cyan}source{reset}.
Can be used to ignore certain strings when sorting by replacing them with an empty string.
For example: {cyan}${{info:autosort_replace,cat,dog,the dog is meowing}}{reset} expands to "the cat is meowing".
{*white}${{info:{brown}autosort_order{white},{cyan}value{white},{cyan}option0{white},{cyan}option1{white},{cyan}option2{white},{cyan}...{white}}}
Generate a zero-padded number that corresponds to the index of {cyan}value{reset} in the list of options.
If one of the options is the special value {brown}*{reset}, then any value not explicitly mentioned will be sorted at that position.
Otherwise, any value that does not match an option is assigned the highest number available.
Can be used to easily sort buffers based on a manual sequence.
For example: {cyan}${{info:autosort_order,${{server}},freenode,oftc,efnet}}{reset} will sort freenode before oftc, followed by efnet and then any remaining servers.
Alternatively, {cyan}${{info:autosort_order,${{server}},freenode,oftc,*,efnet}}{reset} will sort any unlisted servers after freenode and oftc, but before efnet.
{*white}${{info:{brown}autosort_escape{white},{cyan}text{white}}}{reset}
Escape commas and backslashes in {cyan}text{reset} by prepending them with a backslash.
This is mainly useful to pass arbitrary eval strings as arguments to other autosort info hooks.
Otherwise, an eval string that expands to something with a comma would be interpreted as multiple arguments.
For example, it can be used to safely pass buffer names to {cyan}${{info:autosort_replace}}{reset} like so:
{cyan}${{info:autosort_replace,##,#,${{info:autosort_escape,${{buffer.name}}}}}}{reset}.
{*white}# Description {*white}# Description
Autosort is a weechat script to automatically keep your buffers sorted. The sort 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 order can be customized by defining your own sort rules, but the default should
@ -934,17 +979,6 @@ 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 a helper variable named `{cyan}foo{reset}` can be accessed in a main rule with the
string `{cyan}${{foo}}{reset}`. 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} {*white}# Automatic or manual sorting{reset}
By default, autosort will automatically sort your buffer list whenever a buffer 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 is opened, merged, unmerged or renamed. This should keep your buffers sorted in
@ -973,15 +1007,29 @@ structure with the following setting (modify to suit your need):
command_completion = '%(plugin_autosort) %(plugin_autosort) %(plugin_autosort) %(plugin_autosort) %(plugin_autosort)' command_completion = '%(plugin_autosort) %(plugin_autosort) %(plugin_autosort) %(plugin_autosort) %(plugin_autosort)'
info_replace_description = 'Replace all occurences of `from` with `to` in the string `text`.' info_replace_description = (
info_replace_arguments = 'from,to,text' 'Replace all occurrences of `pattern` with `replacement` in the string `source`. '
'Can be used to ignore certain strings when sorting by replacing them with an empty string. '
'See /help autosort for examples.'
)
info_replace_arguments = 'pattern,replacement,source'
info_order_description = ( info_order_description = (
'Get a zero padded index of a value in a list of possible values.' 'Generate a zero-padded number that corresponds to the index of `value` in the list of options. '
'If the value is not found, the index for `*` is returned.' 'If one of the options is the special value `*`, then any value not explicitly mentioned will be sorted at that position. '
'If there is no `*` in the list, the highest index + 1 is returned.' 'Otherwise, any value that does not match an option is assigned the highest number available. '
'Can be used to easily sort buffers based on a manual sequence. '
'See /help autosort for examples.'
) )
info_order_arguments = 'value,first,second,third,...' info_order_arguments = 'value,first,second,third,...'
info_escape_description = (
'Escape commas and backslashes in `text` by prepending them with a backslash. '
'This is mainly useful to pass arbitrary eval strings as arguments to other autosort info hooks. '
'Otherwise, an eval string that expands to something with a comma would be interpreted as multiple arguments.'
'See /help autosort for examples.'
)
info_escape_arguments = 'text'
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
@ -1014,6 +1062,7 @@ if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
weechat.hook_config('autosort.*', 'on_config_changed', '') weechat.hook_config('autosort.*', 'on_config_changed', '')
weechat.hook_completion('plugin_autosort', '', 'on_autosort_complete', '') weechat.hook_completion('plugin_autosort', '', 'on_autosort_complete', '')
weechat.hook_command('autosort', command_description.format(**colors), '', '', command_completion, 'on_autosort_command', '') weechat.hook_command('autosort', command_description.format(**colors), '', '', command_completion, 'on_autosort_command', '')
weechat.hook_info('autosort_escape', info_escape_description, info_escape_arguments, 'on_info_escape', '')
weechat.hook_info('autosort_replace', info_replace_description, info_replace_arguments, 'on_info_replace', '') 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', '') weechat.hook_info('autosort_order', info_order_description, info_order_arguments, 'on_info_order', '')

File diff suppressed because it is too large Load Diff

View File

@ -1,89 +0,0 @@
# Copyright (c) 2013 Shawn Smith <ShawnSmith0828@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
# 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/>.
def weechat_init
# Register our plugin with WeeChat
Weechat.register("auth",
"Shawn Smith",
"0.3",
"GPL3",
"Automatically authenticate with NickServ using your sasl_username and sasl_password.",
"",
"")
Weechat.hook_command("auth",
"Automatically authenticate with NickServ using your sasl_username and sasl_password.",
"list [server]",
"list: Displays your sasl_username and sasl_password",
"",
"auth_command_cb",
"")
# Grab the hook for notices.
Weechat.hook_signal("*,irc_in_notice", "auth_notice_cb", "")
return Weechat::WEECHAT_RC_OK
end
# The auth command
def auth_command_cb(data, buffer, args)
server = buffer.split(',')[0]
arg = args.split(' ')
# Check to make sure we were given a valid option.
if arg[0] == "list" && arg[1]
server = arg[1]
# Grab the pointers from the config
sasl_username = Weechat.config_get("irc.server.#{server}.sasl_username")
sasl_password = Weechat.config_get("irc.server.#{server}.sasl_password")
# Print the usernames/passwords
Weechat.print("", "[Auth]: sasl_username: #{Weechat.string_eval_expression("#{wee_string(sasl_username)}", {}, {}, {})}")
Weechat.print("", "[Auth]: sasl_password: #{Weechat.string_eval_expression("#{wee_string(sasl_password)}", {}, {}, {})}")
else
Weechat.command("", "/help auth")
end
return Weechat::WEECHAT_RC_OK
end
# The incoming notice.
def auth_notice_cb(data, buffer, args)
# Notice should come from nickserv, otherwise we ignore it.
if /^:NickServ!.+:This nickname is registered/i =~ args
# Get the server that we're on.
server = buffer.split(',')[0]
# Grab the username/passwords if we have them.
sasl_username = Weechat.config_get("irc.server.#{server}.sasl_username")
sasl_password = Weechat.config_get("irc.server.#{server}.sasl_password")
# Prevents us from sending empty passwords.
if sasl_password != nil
Weechat.command("", "/quote -server #{server} PRIVMSG NickServ IDENTIFY #{Weechat.string_eval_expression("#{wee_string(sasl_username)}", {}, {}, {})} #{Weechat.string_eval_expression("#{wee_string(sasl_password)}", {}, {}, {})}")
# Backwards compatibility hack for shitty servers that don't let you use [nick pass]
Weechat.command("", "/quote -server #{server} PRIVMSG NickServ IDENTIFY #{Weechat.string_eval_expression("#{wee_string(sasl_password)}", {}, {}, {})}")
end
end
return Weechat::WEECHAT_RC_OK
end
def wee_string(input)
return Weechat.config_string(input)
end

View File

@ -1 +0,0 @@
../auth.rb

View File

@ -15,7 +15,7 @@ diff_color = on
diff_command = "auto" diff_command = "auto"
display_source = on display_source = on
quiet_actions = on quiet_actions = on
sort = "p,n" sort = "i,p,n"
translate_description = on translate_description = on
use_keys = on use_keys = on