Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Commit

Permalink
get the nickserv plugin! Quick!!
Browse files Browse the repository at this point in the history
  • Loading branch information
Chew committed Dec 3, 2017
1 parent b60bef7 commit 42c8321
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions plugins/nickserv.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class NickServ
include Cinch::Plugin

listen_to :connect, method: :identify
match /nsregister (.+) (.+)/, method: :register
match /nsverify (.+)/, method: :verify

def identify(_m)
unless CONFIG['nickservpass'].nil? || CONFIG['nickservpass'] == ''
User('NickServ').send("identify #{CONFIG['nickservpass']}")
end
end

def register(m, pass, email)
if m.user.host == CONFIG['ownerhost']
User('NickServ').send("register #{pass} #{email}")
CONFIG['nickservpass'] = pass.to_s
File.open('config.yaml', 'w') { |f| f.write CONFIG.to_yaml }
m.reply 'I sent verification to nickserv. It might need to verify the email. In that case, type `!nsverify [code]` to verify it. Otherwise, the password has been logged into the config and it will auto-authenticate on startup!'
else
m.reply 'You are not permitted to do this action!'
end
end

def verify(m, code)
if m.user.host == CONFIG['ownerhost']
User('NickServ').send("verify register #{CONFIG['nickname']} #{code}")
m.reply 'Hey! NickServ verified!'
else
m.reply 'You are not permitted to do this action!'
end
end
end

0 comments on commit 42c8321

Please sign in to comment.