Class: Artaius::Plugins::Archivarius

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

Overview

The plugin handles registration of users. The aim of the plugin is to associate KAG account and IRC authname together.

Instance Method Summary collapse

Instance Method Details

#sign_up(m, kag_nick) ⇒ Object

Internal: Sign up a new player with some restrictions: it won’t sign up neither already registered players, nor players, that doesn’t have IRC autname, nor nonexistent KAG players.

m - The recieved message. kag_nick - The String, represents KAG nickname to be associated with

caller's IRC authanme.

Returns nothing.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/artaius/plugins/archivarius.rb', line 23

def (m, kag_nick)
  authname = m.user.authname
  nick     = m.user.nick

  if authname.nil?
    m.reply I18n.archivarius.authname_required and return
  end

  if already_exists?(authname)
    m.reply I18n.archivarius.exists(nick, authname) and return
  end

  player = KAG::Player.new(kag_nick)

  if player.info['statusMessage'] == 'Player not found'
    m.reply I18n.archivarius.not_found(kag_nick) and return
  end

  Player.create(
    :irc_authname => authname,
    :kag_nick     => player.username,
    :role         => player.role,
    :premium      => player.gold?
  )

  m.reply I18n.archivarius.success
end