File: undernet_challenge.rb

package info (click to toggle)
weechat-scripts 20180330-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,072 kB
  • sloc: python: 44,904; perl: 27,389; ruby: 2,101; lisp: 339; tcl: 244; sh: 8; makefile: 7
file content (37 lines) | stat: -rw-r--r-- 1,381 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Copyright (c) 2013, Daniel Bretoi <daniel@bretoi.com>
# Released under BSD license.

require 'net/http'
require 'net/https'
require 'uri'

SCRIPT_NAME    = 'undernet_challenge'
SCRIPT_AUTHOR  = 'Daniel Bretoi <daniel@bretoi.com>'
SCRIPT_DESC    = 'respond to undernet challenge when theres no identd. Example: Ident broken or disabled, to continue to connect you must type /QUOTE PASS 29079'
SCRIPT_VERSION = '0.1.0'
SCRIPT_LICENSE = 'BSD'
SCRIPT_REPO    = 'https://github.com/danielb2/weechat-scripts'

def weechat_init
  Weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", "")
  Weechat.hook_signal("irc_server_connecting", "connecting_cb", "")
  return Weechat::WEECHAT_RC_OK
end

def connecting_cb(data, signal, signal_data)
  @notice_hook ||= Weechat.hook_signal("*,irc_raw_in_notice", "notice_cb", "")
  return Weechat::WEECHAT_RC_OK
end

def notice_cb(data, signal, signal_data)
  if signal_data.include? "Ident broken or disabled, to continue to connect you must type"
    server = signal.split(',')[0]
    passwd = signal_data.split(" ")[-1]
    Weechat.print('',"Sending UnderNet quote pass: #{passwd}")
    corebuf = Weechat.buffer_search_main()
    Weechat.command(corebuf, sprintf("/quote -server %s pass %s", server,passwd))
    Weechat.unhook(@notice_hook)
    @notice_hook = nil
  end
  return Weechat::WEECHAT_RC_OK
end