tcpbot/plugins/RawCmd.rb
oz 21e7d474be updated hooks so acl checks should work for everyone
messed around a lot with Util adding some stuff in there
BotTools is fixed so join/part/stay should be working
Markovian was configured to ignore certain content eg urls
RawCmd is updated to actually spit back error messages, as well
  as inform people when they lack sufficien tACL
Replace just had a <> wrapped around the nick
URLThief is a new idea that just grabs urls as they come into chat
  along with a simple interface for getting random ones or
  regex to find other ones
URLInfo moved to a disabled folder I created for disabled plugins
  as it conflicts with g1mp
Artism as well is a new project, intended for playing ANSI art,
  as well as grabbing it from online and translating it with ansirc
  in real time.
tcpbot just a symlink to extendobot.

Next update: prolly gonna have a ton of ansi files in this bitch.
2021-05-29 20:46:57 -05:00

54 lines
1.6 KiB
Ruby

require 'cinch'
require 'open-uri'
require_relative '../classes/Util.rb'
class RawCmd
include Cinch::Plugin
include Hooks::ACLHook
include Util::PluginHelper
set :prefix, /^:/
@clist = %w{exec raw eval}
@@commands["exec"] = ":exec <cmd> - run <cmd> through terminal untouched (requires SUPER ADMIN OVER 9000 PRIVILEGES)";
@@commands["raw"] = ":raw <cmd> - alias for exec. still same privileges lol."
@@commands["eval"] = ":eval <rcode> - evaluate <rcode> as ruby code (requires SUPER ADMIN OVER 9000 PRIVILEGES)";
@@levelRequired = 9001
match /exec (.+)/, method: :raw;
match /raw (.+)/, method: :raw;
match /eval (.+)/, method: :reval;
def raw(m, cmd)
response = ""
if(!aclcheck(m))
e = Util::Util.instance.getExcuse()
response = "#{m.user.nick}: #{e} (yo access level waaay 2 low, playboiiii))"
else
output = IO.popen(cmd, :err => [:child, :out]) do |io|
io.read
end
if($?.success?)
response = output
else
exc = Util::Util.instance.getExcuse()
response = "#{m.user.nick}: #{exc} (there was an error running your command...)\n"
response << "err: #{output}"
end
end
m.reply(response)
end
def reval(m, code)
response = ""
if(!aclcheck(m))
e = Util::Util.instance.getExcuse()
response = "#{e} (YOU LACK THE PROPER ACCESS AND PROLLY R A SKID N E WAZE)"
else
begin
response = eval(code)
rescue Exception => exc
response = exc.to_s.gsub(/for \#.+$/i,"")
end
end
m.reply(response);
end
end