Class: Cinch::Plugins::Identify

Inherits:
Object
  • Object
show all
Includes:
Cinch::Plugin
Defined in:
lib/cinch/plugins/identify.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) challengeauth(m)



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/cinch/plugins/identify.rb', line 47

def challengeauth(m)
  return unless m.user && m.user.nick == "Q"
  return unless [:secure_quakenet, :challengeauth].include?(config[:type])

  if match = m.message.match(/^CHALLENGE (.+?) (.+)$/)
    challenge = match[1]
    @bot.debug "Received challenge '#{challenge}'"

    username = config[:username].irc_downcase(:rfc1459)
    password = config[:password][0,10]

    key = OpenSSL::Digest::SHA256.hexdigest(username + ":" + OpenSSL::Digest::SHA256.hexdigest(password))
    response = OpenSSL::HMAC.hexdigest("SHA256", key, challenge)
    User("Q@CServe.quakenet.org").send("CHALLENGEAUTH #{username} #{response} HMAC-SHA-256")
  end
end

- (Object) identified_nickserv(m)



39
40
41
42
43
44
# File 'lib/cinch/plugins/identify.rb', line 39

def identified_nickserv(m)
  if m.user == User("nickserv") && config[:type] == :nickserv
    debug "Identified with NickServ"
    @bot.handlers.dispatch :identified, m
  end
end

- (Object) identified_quakenet(m)



65
66
67
68
69
70
# File 'lib/cinch/plugins/identify.rb', line 65

def identified_quakenet(m)
  if m.user == User("q") && [:quakenet, :secure_quakenet, :challengeauth].include?(config[:type])
    debug "Identified with Q"
    @bot.handlers.dispatch(:identified, m)
  end
end

- (Object) identified_userserv(m)



73
74
75
76
77
78
79
# File 'lib/cinch/plugins/identify.rb', line 73

def identified_userserv(m)
  service_name = config[:service_name] || "UserServ"
  if m.user == User(service_name) && config[:type] == :userserv
    debug "Identified with UserServ"
    @bot.handlers.dispatch :identified, m
  end
end

- (Object) identify(m)



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cinch/plugins/identify.rb', line 10

def identify(m)
  case config[:type]
  when :quakenet
    debug "Identifying with Q"
    identify_quakenet
  when :dalnet
    debug "Identifying with Nickserv on DALnet"
    identify_dalnet
  when :secure_quakenet, :challengeauth
    debug "Identifying with Q, using CHALLENGEAUTH"
    identify_secure_quakenet
  when :nickserv
    debug "Identifying with NickServ"
    identify_nickserv
  when :kreynet
    debug "Identifying with K on KreyNet"
    identify_kreynet
  when :userserv
    debug "Identifying with UserServ"
    identify_userserv
  else
    debug "Not going to identify with unknown type #{config[:type].inspect}"
  end
end