Sha256: 1fc9cda14bf761cbdbdb15a3c6552be8da78dcc833c52d82e2acd58210970ac0

Contents?: true

Size: 1.2 KB

Versions: 17

Compression:

Stored size: 1.2 KB

Contents

hook(type: :ujoin) do |dat|
  dat[:plug].users[dat[:nick]] = {} unless dat[:plug].users[dat[:nick]]
  u = dat[:plug].users[dat[:nick]]
  u[:nick] = dat[:nick]
  u[:user] = dat[:user]
  u[:host] = dat[:host]

  unless dat[:plug].chans[dat[:channel]]
    dat[:plug].chans[dat[:channel]] = {}
    dat[:plug].chans[dat[:channel]][:users] = []
  end

  dat[:plug].chans[dat[:channel]][:users] << u[:nick] unless
    dat[:plug].chans[dat[:channel]][:users].include? u[:nick]
end

hook(type: :upart) do |dat|
  dat[:plug].users[dat[:nick]] = {} unless dat[:plug].users[dat[:nick]]
  u = dat[:plug].users[dat[:nick]]
  u[:nick] = dat[:nick]
  u[:user] = dat[:user]
  u[:host] = dat[:host]

  unless dat[:plug].chans[dat[:channel]]
    dat[:plug].chans[dat[:channel]] = {}
    dat[:plug].chans[dat[:channel]][:users] = []
  end

  dat[:plug].chans[dat[:channel]][:users].delete u[:nick] if
    dat[:plug].chans[dat[:channel]][:users].include? u[:nick]

  if dat[:nick] == dat[:plug].nick && /requested by .*/.match(dat[:message])
    dat[:plug].join(dat[:channel])
  end
end

hook(type: :uqit) do |dat|
  dat[:plug].chans.each do |chan|
    chan[:users].delete(dat[:nick]) if chan[:users]
  end
  dat[:plug].users.delete(dat[:nick])
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
protonbot-0.3.4 lib/protonbot/core_plugin/hooks/joinpart.rb
protonbot-0.3.3 lib/protonbot/core_plugin/hooks/joinpart.rb
protonbot-0.3.2 lib/protonbot/core_plugin/hooks/joinpart.rb
protonbot-0.3.1 lib/protonbot/core_plugin/hooks/joinpart.rb
protonbot-0.3.0 lib/protonbot/core_plugin/hooks/joinpart.rb
protonbot-0.2.7 lib/protonbot/core_plugin/hooks/joinpart.rb
protonbot-0.2.6 lib/protonbot/core_plugin/hooks/joinpart.rb
protonbot-0.2.5 lib/protonbot/core_plugin/hooks/joinpart.rb
protonbot-0.2.4 lib/protonbot/core_plugin/hooks/joinpart.rb
protonbot-0.2.3 lib/protonbot/core_plugin/hooks/joinpart.rb
protonbot-0.2.2 lib/protonbot/core_plugin/hooks/joinpart.rb
protonbot-0.2.1 lib/protonbot/core_plugin/hooks/joinpart.rb
protonbot-0.2.0 lib/protonbot/core_plugin/hooks/joinpart.rb
protonbot-0.1.3 lib/protonbot/core_plugin/hooks/joinpart.rb
protonbot-0.1.2 lib/protonbot/core_plugin/hooks/joinpart.rb
protonbot-0.1.1 lib/protonbot/core_plugin/hooks/joinpart.rb
protonbot-0.1.0 lib/protonbot/core_plugin/hooks/joinpart.rb