From 16200fac9ca11b04b5fd03cb8826ae44afb1bcf9 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Wed, 24 Jul 2019 12:03:29 -0400 Subject: [PATCH] stripcolors function --- fish/.config/fish/config.fish | 7 +- fish/.config/fish/functions/stripcolors.fish | 3 + fish/.config/fish/functions/tht.fish | 8 + weechat/.weechat/alias.conf | 1 + weechat/.weechat/irc.conf | 92 +++++- weechat/.weechat/perl/autoload/rslap.pl | 1 - weechat/.weechat/perl/rslap.pl | 309 ------------------- weechat/.weechat/relay.conf | 3 +- 8 files changed, 104 insertions(+), 320 deletions(-) create mode 100644 fish/.config/fish/functions/stripcolors.fish create mode 100644 fish/.config/fish/functions/tht.fish delete mode 120000 weechat/.weechat/perl/autoload/rslap.pl delete mode 100644 weechat/.weechat/perl/rslap.pl diff --git a/fish/.config/fish/config.fish b/fish/.config/fish/config.fish index b1baa18..5c1cbc6 100755 --- a/fish/.config/fish/config.fish +++ b/fish/.config/fish/config.fish @@ -16,10 +16,9 @@ if test -d /usr/local/go set -x GOPATH (/usr/local/go/bin/go env GOPATH) end -set my_paths ~/bin /usr/local/go/bin ~/.yarn/bin $GOPATH/bin ~/.local/bin ~/.cargo/bin /snap/bin ~/.fzf/bin -for path in $my_paths - if test -d $path; and not echo $fish_user_paths | grep -q "$path"; and not echo $PATH | grep -q "$path" - set -x fish_user_paths $fish_user_paths $path +for i in ~/bin /usr/local/go/bin ~/.yarn/bin $GOPATH/bin ~/.local/bin ~/.cargo/bin /snap/bin ~/.fzf/bin + if test -d $i; and not contains $i $PATH + set -x fish_user_paths $fish_user_paths $i end end diff --git a/fish/.config/fish/functions/stripcolors.fish b/fish/.config/fish/functions/stripcolors.fish new file mode 100644 index 0000000..9acda7b --- /dev/null +++ b/fish/.config/fish/functions/stripcolors.fish @@ -0,0 +1,3 @@ +function stripcolors + sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" +end diff --git a/fish/.config/fish/functions/tht.fish b/fish/.config/fish/functions/tht.fish new file mode 100644 index 0000000..177a066 --- /dev/null +++ b/fish/.config/fish/functions/tht.fish @@ -0,0 +1,8 @@ +# Defined in /tmp/fish.aHcCMP/tht.fish @ line 2 +function tht + if test -f ~/.tht/bin/tht.php + php ~/.tht/bin/tht.php $argv + else + echo tht not installed + end +end diff --git a/weechat/.weechat/alias.conf b/weechat/.weechat/alias.conf index 53878bb..1d2262e 100644 --- a/weechat/.weechat/alias.conf +++ b/weechat/.weechat/alias.conf @@ -35,6 +35,7 @@ MUB = "unban *" N = "names" NS = "quote nickserv" OS = "quote operserv" +pbcmd = "/exec -o -sh $* | pb" py = "/exec -o python3 -c "print($*)"" Q = "query" rainbow = "/exec -o toilet --irc --gay -f term -- $*" diff --git a/weechat/.weechat/irc.conf b/weechat/.weechat/irc.conf index ef50bdb..b8e7571 100644 --- a/weechat/.weechat/irc.conf +++ b/weechat/.weechat/irc.conf @@ -181,7 +181,7 @@ tilde.local_hostname tilde.usermode tilde.command = "/oper root ${sec.data.tildenetoper}; /msg operserv login ${sec.data.pass}" tilde.command_delay -tilde.autojoin = "#chaos,#meta,#opers,#secret-sudoers,#team,#sudoers,#yourtilde,#music,#politics,#gopher,#tildeverse,#idlerpg,#tilderadio,#minecraft,#tildelinux,#slbr,#cosmic,#institute,#.tilde,#tildetel,#dcss,#center,#thunix,#theasylum,#minetest,#aussie,#uucp,#projects,#hamradio,#vim,#black,#pink,#modded,#vh7,#cervezafria,#~,#netnews,#admin,#bots,#ctrl-c,#bitbot,#radiofreqs :57:60,:10:20" +tilde.autojoin = "#chaos,#meta,#opers,#secret-sudoers,#team,#sudoers,#YourTilde,#music,#politics,#gopher,#tildeverse,#idlerpg,#tilderadio,#minecraft,#tildelinux,#cosmic,#institute,#.tilde,#tildetel,#center,#thunix,#theasylum,#minetest,#aussie,#uucp,#projects,#hamradio,#vim,#black,#pink,#vh7,#~,#netnews,#admin,#bots,#ctrl-c,#bitbot,#radiofreqs,#brains :57:60,:10:20" tilde.autorejoin tilde.autorejoin_delay tilde.connection_timeout @@ -263,7 +263,7 @@ town.local_hostname town.usermode town.command town.command_delay -town.autojoin = "#tildetown,#bots,#dumpsterfire,#tildemush,#counting,#movienight,#counting-meta,#heavy,#quiet,#counting-anarchy,#soup,#alc,#queer,#math" +town.autojoin = "#tildetown,#bots,#dumpsterfire,#tildemush,#counting,#movienight,#counting-meta,#heavy,#quiet,#counting-anarchy,#alc,#queer,#math" town.autorejoin town.autorejoin_delay town.connection_timeout @@ -468,7 +468,7 @@ freenode.local_hostname freenode.usermode freenode.command freenode.command_delay -freenode.autojoin = "#weechat,##oodnet,#lobsters,#lobsters-boil,#gitea,#mastodon,#pleroma,#pleroma-offtopic,#oragono,#weechat-android,#git,#tilde.team,#sr.ht,#cmpwn,#gopherproject,#bitreich-en,#bitbot,#bitreich-de,#ircv3,#gophernicus,##jan6,##ircv3-offtopic,#disroot,#thelounge,#tilde.team-offtopic 6:10" +freenode.autojoin = "#weechat,##oodnet,#lobsters,#lobsters-boil,#gitea,#mastodon,#pleroma,#pleroma-offtopic,#oragono,#weechat-android,#git,#tilde.team,#sr.ht,#cmpwn,#gopherproject,#bitreich-en,#bitbot,#bitreich-de,#ircv3,#gophernicus,##jan6,##ircv3-offtopic,#disroot,#thelounge,#ovh,#elixir-lang,#ascii.town,#sonarr,#systemd,#python 6:10" freenode.autorejoin freenode.autorejoin_delay freenode.connection_timeout @@ -591,7 +591,7 @@ slashnet.local_hostname slashnet.usermode slashnet.command slashnet.command_delay -slashnet.autojoin = "#gtlug" +slashnet.autojoin = "#gtlug,#mefi" slashnet.autorejoin slashnet.autorejoin_delay slashnet.connection_timeout @@ -714,7 +714,7 @@ darenet.local_hostname darenet.usermode darenet.command darenet.command_delay -darenet.autojoin = "#bitbot,#DareNET,#chat ,44" +darenet.autojoin = "#DareNET,#chat" darenet.autorejoin darenet.autorejoin_delay darenet.connection_timeout @@ -727,3 +727,85 @@ darenet.msg_part darenet.msg_quit darenet.notify darenet.split_msg_max_length +irc.com.addresses = "irc.irc.com/6697" +irc.com.proxy +irc.com.ipv6 +irc.com.ssl = on +irc.com.ssl_cert +irc.com.ssl_priorities +irc.com.ssl_dhkey_size +irc.com.ssl_fingerprint +irc.com.ssl_verify +irc.com.password +irc.com.capabilities +irc.com.sasl_mechanism +irc.com.sasl_username = "benharri" +irc.com.sasl_password = "${sec.data.pass}" +irc.com.sasl_key +irc.com.sasl_timeout +irc.com.sasl_fail +irc.com.autoconnect +irc.com.autoreconnect +irc.com.autoreconnect_delay +irc.com.nicks = "benharri,bhh" +irc.com.nicks_alternate +irc.com.username +irc.com.realname +irc.com.local_hostname +irc.com.usermode +irc.com.command +irc.com.command_delay +irc.com.autojoin = "#atheism,#sysadmin,#programming,#beer" +irc.com.autorejoin +irc.com.autorejoin_delay +irc.com.connection_timeout +irc.com.anti_flood_prio_high +irc.com.anti_flood_prio_low +irc.com.away_check +irc.com.away_check_max_nicks +irc.com.msg_kick +irc.com.msg_part +irc.com.msg_quit +irc.com.notify +irc.com.split_msg_max_length +ascii.addresses = "ascii.town/6697" +ascii.proxy +ascii.ipv6 +ascii.ssl = on +ascii.ssl_cert +ascii.ssl_priorities +ascii.ssl_dhkey_size +ascii.ssl_fingerprint +ascii.ssl_verify +ascii.password +ascii.capabilities +ascii.sasl_mechanism +ascii.sasl_username +ascii.sasl_password +ascii.sasl_key +ascii.sasl_timeout +ascii.sasl_fail +ascii.autoconnect +ascii.autoreconnect +ascii.autoreconnect_delay +ascii.nicks +ascii.nicks_alternate +ascii.username +ascii.realname +ascii.local_hostname +ascii.usermode +ascii.command +ascii.command_delay +ascii.autojoin = "&town" +ascii.autorejoin +ascii.autorejoin_delay +ascii.connection_timeout +ascii.anti_flood_prio_high +ascii.anti_flood_prio_low +ascii.away_check +ascii.away_check_max_nicks +ascii.msg_kick +ascii.msg_part +ascii.msg_quit +ascii.notify +ascii.split_msg_max_length diff --git a/weechat/.weechat/perl/autoload/rslap.pl b/weechat/.weechat/perl/autoload/rslap.pl deleted file mode 120000 index ca21dec..0000000 --- a/weechat/.weechat/perl/autoload/rslap.pl +++ /dev/null @@ -1 +0,0 @@ -../rslap.pl \ No newline at end of file diff --git a/weechat/.weechat/perl/rslap.pl b/weechat/.weechat/perl/rslap.pl deleted file mode 100644 index 0229c11..0000000 --- a/weechat/.weechat/perl/rslap.pl +++ /dev/null @@ -1,309 +0,0 @@ -# -# rslap.pl - Random slap strings for weechat 0.3.0 -# Version 1.3.1 -# -# Let's you /slap a nick but with a random string -# Customisable via the 'rslap' file in your config dir -# The rslap file is plain text, with one message per line -# Use '$nick' to denote where a nick should go -# -# Usage: -# /rslap [ -# Slaps with a random slap, entry will use that entry -# number instead of a random one -# -# /rslap_info -# This tells you how many messages there are, and prints them -# -# /rslap_add -# /rslap_remove -# Adds / removes string/id from the available list and attempts -# to update the rslap file -# -# /set plugins.var.perl.rslap.slapback -# Sets the slapback, takes "off", "on/random", or "n" where n -# is a valid entry number - -# History: -# 2010-12-30, KenjiE20 : -# v1.3.1 -fix: uninitialised variable error -# 2010-04-25, KenjiE20 : -# v1.3 -feature: Ability to add/remove entries -# -feature: Can specify which string /rslap will use -# -feature: Slapback with specified/random string -# 2009-08-10, KenjiE20 : -# v1.2: Correct /help format to match weechat base -# 2009-07-28, KenjiE20 : -# v1.1: -fix: Make file loading more robust -# and strip out comments/blank lines -# 2009-07-09, KenjiE20 : -# v1.0: Initial Public Release - -# Copyright (c) 2009-2010 by KenjiE20 -# -# 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 . -# - -weechat::register("rslap", "KenjiE20", "1.3.1", "GPL3", "Slap Randomiser", "", ""); - -$file = weechat::info_get("weechat_dir", "")."/rslap"; -my @lines; -$lastrun = 0; -$rslap_slapback_hook = 0; -rslap_start(); -rslap_slapback_toggle("","",weechat::config_get_plugin ("slapback")); - -sub rslap_start -{ - if (-r $file) - { - weechat::hook_command("rslap", "Slap a nick with a random string", "nickname [entry]", "nickname: Nick to slap\n entry: which entry number to use (/rslap_info for the list)\n\n /set plugins.var.perl.rslap.slapback\n Sets the slapback, takes \"off\", \"on/random\", or \"n\" where n is a valid entry number", "%(nicks)", "rslap", ""); - weechat::hook_command("rslap_info", "Prints out the current strings /rslap will use", "", "", "", "rslap_info", ""); - weechat::hook_command("rslap_add", "Add a new slap entry", "[slap string]", "", "", "rslap_add", ""); - weechat::hook_command("rslap_remove", "Remove a slap entry", "[entry number]", "", "", "rslap_remove", ""); - - weechat::hook_config("plugins.var.perl.rslap.slapback", "rslap_slapback_toggle", ""); - - if (!(weechat::config_is_set_plugin ("slapback"))) - { - weechat::config_set_plugin("slapback", "off"); - } - - open FILE, $file; - @lines = ; - close (FILE); - - foreach (@lines) - { - s/^#.*$//; - chomp; - } - @lines = grep /\S/, @lines; - } - else - { - rslap_make_file(); - } - return weechat::WEECHAT_RC_OK; -} - -sub rslap_info -{ - weechat::print ("", "Number of available strings: ".weechat::color("bold").@lines.weechat::color("-bold")."\n"); - $max_align = length(@lines); - $count = 1; - foreach (@lines) - { - weechat::print ("","\t ".(" " x ($max_align - length($count))).$count.": ".$_."\n"); - $count++; - } - return weechat::WEECHAT_RC_OK; -} - -sub rslap_add -{ - my $text = $_[2] if ($_[2]); - if ($text) - { - push (@lines, $text); - weechat::print("", "Added entry ".@lines." as: \"".$text."\""); - rslap_update_file(); - return weechat::WEECHAT_RC_OK; - } - else - { - return weechat::WEECHAT_RC_OK; - } -} - -sub rslap_remove -{ - my $entry = $_[2] if ($_[2]); - if ($entry =~ m/^\d+/) - { - $entry--; - if ($lines[$entry]) - { - $removed = $lines[$entry]; - $lines[$entry] = ''; - @lines = grep /\S/, @lines; - weechat::print("", "Removed entry ".weechat::color("bold").($entry + 1).weechat::color("-bold")." (".$removed.")"); - rslap_update_file(); - return weechat::WEECHAT_RC_OK; - } - else - { - weechat::print ("", weechat::prefix("error")."Not a valid entry"); - } - } - else - { - return weechat::WEECHAT_RC_OK; - } -} - -sub rslap_slapback_toggle -{ - $point = $_[0]; - $name = $_[1]; - $value = $_[2]; - - if ($value eq "off") - { - if ($rslap_slapback_hook) - { - weechat::unhook($rslap_slapback_hook); - $rslap_slapback_hook = 0; - } - } - elsif ($value ne "off") - { - if (!$rslap_slapback_hook) - { - $rslap_slapback_hook = weechat::hook_print("", "", "", 1, "rslap_slapback_cb", ""); - } - } - return weechat::WEECHAT_RC_OK; -} - -sub rslap -{ - $buffer = $_[1]; - $args = $_[2]; - if (weechat::buffer_get_string($buffer, "plugin") eq "irc") - { - ($nick, $number) = split(/ /,$args); - if ($nick eq "") - { - weechat::print ("", weechat::prefix("error")."No nick given"); - } - else - { - if (defined $number && $number =~ m/^\d+$/) - { - $number--; - if (!$lines[$number]) - { - weechat::print ($buffer, weechat::prefix("error")."Not a valid entry"); - return weechat::WEECHAT_RC_OK; - } - } - else - { - $number = int(rand(@lines)); - } - $str = $lines[$number]; - $str =~ s/\$nick/$nick/; - $lastrun = time; - weechat::command ($buffer, "/me ".$str); - } - } - else - { - weechat::print ($buffer, weechat::prefix("error")."Must be used on an IRC buffer"); - } - return weechat::WEECHAT_RC_OK; -} - -sub rslap_slapback_cb -{ - $cb_datap = $_[0]; - $cb_bufferp = $_[1]; - $cb_date = $_[2]; - $cb_tags = $_[3]; - $cb_disp = $_[4]; - $cb_high = $_[5]; - $cb_prefix = $_[6]; - $cb_msg = $_[7]; - - $bufname = weechat::buffer_get_string($cb_bufferp, 'name'); - # Only do something if a) IRC message b) is an action c) displayed and d) is a channel - if ($cb_tags =~ /irc_privmsg/ && $cb_tags =~ /irc_action/ && $cb_disp eq "1" && $bufname =~ /.*\.[#&\+!].*/) - { - # Anti-recursive - if ((time - $lastrun) < 10) - { - return weechat::WEECHAT_RC_OK; - } - # Strip colour - $cb_msg = weechat::string_remove_color($cb_msg, ""); - # Snip sender from message - $from_nick = substr($cb_msg, 0, index($cb_msg, " ")); - $cb_msg = substr($cb_msg, length($from_nick)); - # check for our nick and slap in message - $cur_nick = weechat::buffer_get_string($cb_bufferp, "localvar_nick"); - if ($from_nick ne $cur_nick && $cb_msg =~ /slap/ && $cb_msg =~ /\s$cur_nick(\s|$)/) - { - if (weechat::config_get_plugin("slapback") =~ m/^\d+$/) - { - rslap("", $cb_bufferp, $from_nick." ".weechat::config_get_plugin("slapback")); - } - else - { - rslap("", $cb_bufferp, $from_nick); - } - } - } - return weechat::WEECHAT_RC_OK; -} - -sub rslap_make_file -{ - weechat::print ("", "Attempting to create default file at: $file"); - - open FILE, ">", $file; - $defs = "slaps \$nick around a bit with a large trout\n". - "gives \$nick a clout round the head with a fresh copy of WeeChat\n". - "slaps \$nick with a large smelly trout\n". - "breaks out the slapping rod and looks sternly at \$nick\n". - "slaps \$nick's bottom and grins cheekily\n". - "slaps \$nick a few times\n". - "slaps \$nick and starts getting carried away\n". - "would slap \$nick, but is not being violent today\n". - "gives \$nick a hearty slap\n". - "finds the closest large object and gives \$nick a slap with it\n". - "likes slapping people and randomly picks \$nick to slap\n". - "dusts off a kitchen towel and slaps it at \$nick"; - print FILE $defs; - close (FILE); - if (!(-r $file)) - { - weechat::print ("", weechat::prefix("error")."Problem creating file: $file\n". - weechat::prefix("error")."Make sure you can write to the location."); - return weechat::WEECHAT_RC_ERROR; - } - else - { - weechat::print ("", "File created at: $file successfully"); - rslap_start(); - return weechat::WEECHAT_RC_OK; - } -} - -sub rslap_update_file -{ - $defs = ''; - foreach (@lines) - { - $defs = $defs."\n".$_; - } - unless(open (FILE, ">", $file)) - { - weechat::print ("", weechat::prefix("error")."Cannot write to file: $file"); - return weechat::WEECHAT_RC_ERROR; - } - print FILE $defs; - close (FILE); - return weechat::WEECHAT_RC_OK; -} diff --git a/weechat/.weechat/relay.conf b/weechat/.weechat/relay.conf index a0d7d5b..975fbad 100644 --- a/weechat/.weechat/relay.conf +++ b/weechat/.weechat/relay.conf @@ -52,6 +52,7 @@ commands = "" [port] irc = 6666 -weechat = 9090 +weechat = 9099 [path] +unix.weechat = "%h/relay_socket"