Module: IRC::Server::Modules::Base::Utils::User
- Defined in:
- lib/failirc/server/modules/Base.rb
Constant Summary collapse
- @@levels =
{ :x => '~', :y => '&', :o => '@', :h => '%', :v => '+', }
- @@levelsOrder =
[:x, :y, :o, :h, :v]
Class Method Summary collapse
- .getHighestLevel(user) ⇒ Object
- .isLevel(char) ⇒ Object
- .isLevelEnough(user, level) ⇒ Object
- .levels ⇒ Object
- .setLevel(user, level, value) ⇒ Object
Class Method Details
.getHighestLevel(user) ⇒ Object
475 476 477 478 479 480 481 482 483 484 485 486 487 |
# File 'lib/failirc/server/modules/Base.rb', line 475 def self.getHighestLevel (user) if user.modes[:x] return :x elsif user.modes[:y] return :y elsif user.modes[:o] return :o elsif user.modes[:h] return :h elsif user.modes[:v] return :v end end |
.isLevel(char) ⇒ Object
444 445 446 |
# File 'lib/failirc/server/modules/Base.rb', line 444 def self.isLevel (char) @@levels.has_value?(char) ? char : false end |
.isLevelEnough(user, level) ⇒ Object
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
# File 'lib/failirc/server/modules/Base.rb', line 448 def self.isLevelEnough (user, level) if !level || (level.is_a?(String) && level.empty?) return true end if level.is_a?(String) level = @@levels.key level end highest = self.getHighestLevel(user) if !highest return false else highest = @@levelsOrder.index(highest) level = @@levelsOrder.index(level) if !level return true elsif !highest return false else return highest <= level end end end |
.levels ⇒ Object
438 439 440 |
# File 'lib/failirc/server/modules/Base.rb', line 438 def self.levels return @@levels end |
.setLevel(user, level, value) ⇒ Object
489 490 491 492 493 494 495 496 497 498 499 500 501 |
# File 'lib/failirc/server/modules/Base.rb', line 489 def self.setLevel (user, level, value) if @@levels[level] Utils::setFlags(user, level, value) if value user.modes[:level] = @@levels[level] else self.setLevel(user, self.getHighestLevel(user), true) end else user.modes[:level] = '' end end |