aboutsummaryrefslogtreecommitdiff
path: root/weechat/ruby
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2017-03-21 18:39:01 +0100
committerneodarz <neodarz@neodarz.net>2017-03-21 18:39:01 +0100
commitf77c0ad912f5d38b9a69deb19bcc9f08d673505d (patch)
tree99e270312a37cf3cf0b05d63bb567536944f8603 /weechat/ruby
parent24a03da38772033e1c72ebb08f3db508d2fabac9 (diff)
parent6353236f1e13aa522325f742d64da5fa7067ec44 (diff)
downloaddotfiles_ascii-f77c0ad912f5d38b9a69deb19bcc9f08d673505d.tar.xz
dotfiles_ascii-f77c0ad912f5d38b9a69deb19bcc9f08d673505d.zip
Merge branch 'master' of ssh://neodarz.net:/home/git/pub_repo/neodarz/scripts_shit/dotfiles_ascii
Diffstat (limited to '')
-rwxr-xr-xweechat/ruby/auth.rb89
l---------weechat/ruby/autoload/auth.rb1
2 files changed, 90 insertions, 0 deletions
diff --git a/weechat/ruby/auth.rb b/weechat/ruby/auth.rb
new file mode 100755
index 0000000..c304cab
--- /dev/null
+++ b/weechat/ruby/auth.rb
@@ -0,0 +1,89 @@
+# 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
diff --git a/weechat/ruby/autoload/auth.rb b/weechat/ruby/autoload/auth.rb
new file mode 120000
index 0000000..08c0b0f
--- /dev/null
+++ b/weechat/ruby/autoload/auth.rb
@@ -0,0 +1 @@
+../auth.rb \ No newline at end of file