Class: Cinch::Plugins::PrivToolbox

Inherits:
Object
  • Object
show all
Includes:
Admin, Cinch::Plugin
Defined in:
lib/cinch/plugins/privtoolbox.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

#act(m, channel, text) ⇒ Object


32
33
34
35
36
# File 'lib/cinch/plugins/privtoolbox.rb', line 32

def act(m, channel, text)
  return unless is_trusted?(m.user)
  Channel(channel).action(text)
  @bot.handlers.dispatch :private_admin, m, "acted in #{channel}: #{text}", m.target
end

#ban(m, channel, user) ⇒ Object


104
105
106
107
108
109
110
111
# File 'lib/cinch/plugins/privtoolbox.rb', line 104

def ban(m, channel, user)
  return unless is_trusted?(m.user)
  channel = Channel(channel)
  user = User(user)
  mask = user.mask("*!*@%h")
  channel.ban(mask)
  @bot.handlers.dispatch :admin, m, "Banned #{user.nick} (#{mask.to_s}) from #{channel.name}", m.target
end

#cs(m, text) ⇒ Object


39
40
41
42
43
# File 'lib/cinch/plugins/privtoolbox.rb', line 39

def cs(m, text)
  return unless is_admin?(m.user)
  User("chanserv").send(text)
  @bot.handlers.dispatch :private_admin, m, "chanserv: #{text}", m.target
end

#hs(m, text) ⇒ Object


76
77
78
79
80
# File 'lib/cinch/plugins/privtoolbox.rb', line 76

def hs(m, text)
  return unless is_admin?(m.user)
  User("hostserv").send(text)
  @bot.handlers.dispatch :private_admin, m, "hostserv: #{text}", m.target
end

#kick(m, channel, user, msg) ⇒ Object


94
95
96
97
98
99
100
101
# File 'lib/cinch/plugins/privtoolbox.rb', line 94

def kick(m, channel, user, msg)
  return unless is_trusted?(m.user)
  msg ||= m.user.nick
  channel = Channel(channel)
  user = User(user)
  channel.kick(user, msg)
  @bot.handlers.dispatch :admin, m, "Kicked #{user.nick} from #{channel.name}#{" - \"#{msg}\"" unless msg.nil?}", m.target
end

#kickban(m, channel, user, msg) ⇒ Object


122
123
124
125
126
127
128
129
130
131
# File 'lib/cinch/plugins/privtoolbox.rb', line 122

def kickban(m, channel, user, msg)
  return unless is_trusted?(m.user)
  msg ||= m.user.nick
  channel = Channel(channel)
  user = User(user)
  mask = user.mask("*!*@%h")
  channel.ban(mask)
  channel.kick(user, msg)
  @bot.handlers.dispatch :admin, m, "Kickbanned #{user} (#{mask.to_s}) from #{channel.name}#{" - \"#{msg}\"" unless msg.nil?}", m.target
end

#msg(m, user, text) ⇒ Object


25
26
27
28
29
# File 'lib/cinch/plugins/privtoolbox.rb', line 25

def msg(m, user, text)
  return unless is_trusted?(m.user)
  User(user).send(text)
  @bot.handlers.dispatch :private_admin, m, "said to #{user}: #{text}", m.target
end

#ns(m, text) ⇒ Object


69
70
71
72
73
# File 'lib/cinch/plugins/privtoolbox.rb', line 69

def ns(m, text)
  return unless is_admin?(m.user)
  User("nickserv").send(text)
  @bot.handlers.dispatch :private_admin, m, "nickserv: #{text}", m.target
end

#psa(m, text) ⇒ Object


83
84
85
86
87
88
89
# File 'lib/cinch/plugins/privtoolbox.rb', line 83

def psa(m, text)
  return unless is_admin?(m.user)
  @bot.channels.each {|channel|
    channel.safe_notice "[#{m.user.nick}] #{text}"
  }
  @bot.handlers.dispatch :admin, m, "Public service announcement: #{text}", m.target
end

#reidentify(m) ⇒ Object


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/cinch/plugins/privtoolbox.rb', line 46

def reidentify(m)
  return unless is_admin?(m.user)
  identify_plugin = @bot.plugins.find {|plugin| plugin.class == Cinch::Plugins::Identify }
  if identify_plugin
    identify_plugin.identify(nil)
  elsif @bot.config.sasl.password
    @bot.handlers.dispatch :private_admin, m, "Attempting to use SASL password for nickserv identification...", m.target
    User("nickserv").send("release @bot.last_nick #{@bot.config.sasl.password}")
    @bot.nick = @bot.last_nick
    User("nickserv").send("identify #{@bot.config.sasl.password}")
  else
    if @bot.config.password
      @bot.handlers.dispatch :private_admin, m, "Cinch::Plugins::Identify is not configured! Attempting to use server password for nickserv identification...", m.target
      User("nickserv").send("release @bot.last_nick #{@bot.config.password}")
      @bot.nick = @bot.last_nick
      User("nickserv").send("identify #{@bot.config.password}")
    else
      @bot.handlers.dispatch :private_admin, m, "Neither Cinch::Plugins::Identify, server password, nor SASL password is not configured; cannot re-identify to services.", m.target
    end
  end
end

#say(m, channel, text) ⇒ Object


18
19
20
21
22
# File 'lib/cinch/plugins/privtoolbox.rb', line 18

def say(m, channel, text)
  return unless is_trusted?(m.user)
  Channel(channel).send(text)
  @bot.handlers.dispatch :private_admin, m, "said in #{channel}: #{text}", m.target
end

#unban(m, channel, mask) ⇒ Object


114
115
116
117
118
119
# File 'lib/cinch/plugins/privtoolbox.rb', line 114

def unban(m, channel, mask)
  return unless is_trusted?(m.user)
  channel = Channel(channel)
  channel.unban(mask)
  @bot.handlers.dispatch :admin, m, "Unbanned #{mask} from #{channel.name}", m.target
end