Class: Cinch::Plugins::RemoteAdmin

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

Constant Summary

Constants included from Admin

Admin::TYPES

Instance Method Summary collapse

Methods included from Admin

#add_admin, #add_trusted, #delete_admin, #delete_trusted, #each_controlchannel, #each_online_admin, #each_online_trusted, #get_admins, #get_trusted, #is_admin?, #is_trusted?, #no_admins?

Methods included from Helpers

#check_user, #is_channel_disabled?, table_format

Instance Method Details

#listen_ctcp(m, message = nil, target = nil) ⇒ Object


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/cinch/plugins/remoteadmin.rb', line 38

def listen_ctcp(m, message = nil, target = nil)
  synchronize(:remoteadmn) do
    return if !m.ctcp? || m.action?
    return if m.ctcp_command.eql?('PING')
    if m.user.nick =~ /^.+serv$/i
      each_online_admin {|admin|
        admin.notice prettify(nick: m.user.nick, source: m.target.name, type: "CTCP", string: m.ctcp_message)
      }
    else
      each_controlchannel {|channel|
        channel.msg prettify(nick: m.user.nick, source: m.target.name, type: "CTCP", string: m.ctcp_message)
      }
    end
  end
end

#listen_hook(m, message, target) ⇒ Object


55
56
57
58
59
60
61
# File 'lib/cinch/plugins/remoteadmin.rb', line 55

def listen_hook(m, message, target)
  synchronize(:remoteadmn) do
    each_controlchannel {|channel|
      channel.msg prettify(nick: m.user.nick, source: m.target.name, type: "ADMIN", string: message)
    }
  end
end

#listen_notice(m, message = nil, target = nil) ⇒ Object


22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cinch/plugins/remoteadmin.rb', line 22

def listen_notice(m, message = nil, target = nil)
  synchronize(:remoteadmn) do
    return if m.ctcp? || !m.user
    if m.user.nick =~ /^.+serv$|^global$/i
      each_online_admin {|admin|
        admin.notice prettify(nick: m.user.nick, source: m.target.name, type: m.command, string: m.message)
      }
    else
      each_controlchannel {|channel|
        channel.msg prettify(nick: m.user.nick, source: m.target.name, type: m.command, string: m.message)
      }
    end
  end
end

#listen_private(m, message = nil, target = nil) ⇒ Object


12
13
14
15
16
17
18
19
# File 'lib/cinch/plugins/remoteadmin.rb', line 12

def listen_private(m, message = nil, target = nil)
  synchronize(:remoteadmn) do
    return if m.ctcp? || m.events.include?(:notice)
    each_online_admin {|admin|
      admin.notice prettify(nick: m.user.nick, source: m.target.name, type: m.command, string: m.message)
    }
  end
end

#private_listen_hook(m, message, target) ⇒ Object


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

def private_listen_hook(m, message, target)
  synchronize(:remoteadmn) do
    each_online_admin {|admin|
      admin.notice prettify(nick: m.user.nick, source: m.target.name, type: "P.ADMIN", string: message)
    }
  end
end

#timeban_listen_hook(m, message, target) ⇒ Object


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

def timeban_listen_hook(m, message, target)
  synchronize(:remoteadmn) do
    each_controlchannel {|channel|
      channel.msg prettify(nick: m.user.nick, source: m.target.name, type: "TIMEBAN", string: message)
    }
  end
end