Class: KAG::IRC::Plugin

Inherits:
Object
  • Object
show all
Includes:
Cinch::Commands, Cinch::Plugin, Common
Defined in:
lib/kag/irc/plugin.rb

Instance Method Summary collapse

Methods included from Common

#_h, #debug, #is_admin, #is_banned?, #reply, #send_channels_msg

Methods included from Cinch::Commands

included

Instance Method Details

#authed(m) ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/kag/irc/plugin.rb', line 51

def authed(m)
  m.user.refresh
  if m.user.authed?
    reply m,"#{m.user.nick} is authed."
  else
    reply m,"#{m.user.nick} is not yet authed. Please type !help to get help with authenticating."
  end
end

#authname(m, nick) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/kag/irc/plugin.rb', line 63

def authname(m,nick)
  if is_admin(m.user)
    user = User(nick)
    user.refresh
    if user and !user.unknown
      reply m,"Authname for #{nick} is #{user.authname}"
    else
      reply m,"Could not find user #{nick}"
    end
  end
end

#deop(m, nick, channel = nil) ⇒ Object



108
109
110
111
112
113
114
115
116
117
# File 'lib/kag/irc/plugin.rb', line 108

def deop(m,nick,channel = nil)
  if is_admin(m.user)
    if channel
      c = Channel(channel)
      c.deop(nick) if c
    else
      m.channel.deop(nick)
    end
  end
end

#devoice(m, nick, channel = nil) ⇒ Object



136
137
138
139
140
141
142
143
144
145
# File 'lib/kag/irc/plugin.rb', line 136

def devoice(m,nick,channel = nil)
  if is_admin(m.user)
    if channel
      c = Channel(channel)
      c.devoice(nick) if c
    else
      m.channel.devoice(nick)
    end
  end
end

#hostname(m, nick) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/kag/irc/plugin.rb', line 15

def hostname(m,nick)
  if is_admin(m.user)
    user = User(nick)
    if user and !user.unknown
      reply m,"Hostname for #{nick} is #{user.host}"
    else
      reply m,"Could not find user #{nick}"
    end
  end
end

#idle(m, nick) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/kag/irc/plugin.rb', line 78

def idle(m,nick)
  if is_admin(m.user)
    user = User(nick)
    user.refresh
    if user and !user.unknown
      s = user.idle.to_i / 60
      reply m,"#{nick} has been idle #{s} minutes"
    else
      reply m,"Could not find user #{nick}"
    end
  end
end

#kick(m, nick, reason = "", channel = nil) ⇒ Object



150
151
152
153
154
155
156
157
158
159
# File 'lib/kag/irc/plugin.rb', line 150

def kick(m,nick,reason = "",channel = nil)
  if is_admin(m.user)
    if channel
      c = Channel(channel)
      c.kick(nick,reason) if c
    else
      m.channel.kick(nick,reason)
    end
  end
end

#op(m, nick, channel = nil) ⇒ Object



94
95
96
97
98
99
100
101
102
103
# File 'lib/kag/irc/plugin.rb', line 94

def op(m,nick,channel = nil)
  if is_admin(m.user)
    if channel
      c = Channel(channel)
      c.op(nick) if c
    else
      m.channel.op(nick)
    end
  end
end

#refresh(m) ⇒ Object



30
31
32
33
# File 'lib/kag/irc/plugin.rb', line 30

def refresh(m)
  m.user.refresh
  m.reply "#{m.user.nick} refreshed as #{m.user.authname}."
end

#refresh_specific(m, nick) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/kag/irc/plugin.rb', line 39

def refresh_specific(m,nick)
  if is_admin(m.user)
    u = User(nick)
    if u
      u.refresh
      m.reply "#{u.nick} refreshed as #{u.authname}."
    end
  end
end

#voice(m, nick, channel = nil) ⇒ Object



122
123
124
125
126
127
128
129
130
131
# File 'lib/kag/irc/plugin.rb', line 122

def voice(m,nick,channel = nil)
  if is_admin(m.user)
    if channel
      c = Channel(channel)
      c.voice(nick) if c
    else
      m.channel.voice(nick)
    end
  end
end