Advertisement
Stiepen

#ccbots esper.net bot muting script

Sep 29th, 2012
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.32 KB | None | 0 0
  1. local channels = {}
  2. local users = {}
  3. local npt = print
  4. local accesswhitelist = {"N".."ia", "Cru".."or", "Kilo".."byte", "Ke".."vin_", "Clo".."udy", "dan".."200", "Stary".."2001", "AfterLife".."Lochie", "Du".."cky"}
  5. --nnxt = next
  6. --hide = {nnxt = true, hide = true, accesswhitelist = true, npt = true, users = true, channels = true}
  7.  
  8. function iswlisted(user)
  9.   for _, v in ipairs(accesswhitelist) do
  10.     if v:lower() == user:lower() then return true end
  11.   end
  12.   return false
  13. end
  14.  
  15. function print(...)
  16.   if (not (channels[irc_channel] or users[irc_nick])) or iswlisted(irc_nick) then
  17.     npt(...)
  18.   end
  19. end
  20.  
  21. local function muteu(u)
  22.   if not iswlisted(irc_nick) then return end
  23.   if iswlisted(u) then
  24.     npt(u.." can not be muted")
  25.   else
  26.     if users[u] then
  27.       npt(u.."is already muted.")
  28.       return
  29.     end
  30.     users[u] = true
  31.     npt("Locked outputs for "..u)
  32.   end
  33. end
  34.  
  35. local function mutec()
  36.   if not iswlisted(irc_nick) then return end
  37.   if channels[irc_channel] then
  38.     npt("Already muted in "..irc_channel)
  39.     return
  40.   end
  41.   channels[irc_channel] = true
  42.   npt("Now muted in "..irc_channel)
  43. end
  44.  
  45. function mute(user)
  46.   if iswlisted(irc_nick) then
  47.     if user then
  48.       muteu(user)
  49.     else
  50.       mutec()
  51.     end
  52.   else
  53.     error("Access denied")
  54.   end
  55. end
  56.  
  57. local function umuteu(user)
  58.   if not iswlisted(irc_nick) then return end
  59.   if not users[user] then
  60.     npt(user.." is not muted")
  61.     return
  62.   end
  63.   users[user] = nil
  64.   npt("Unmuted "..user)
  65. end
  66.  
  67. local function umutec()
  68.   if not iswlisted(irc_nick) then return end
  69.   if not channels[irc_channel] then
  70.     npt("Not muted.")
  71.     return
  72.   end
  73.   channels[irc_channel] = nil
  74.   npt("Unmuted in "..irc_channel)
  75. end
  76.  
  77. function unmute(user)
  78.   if iswlisted(irc_nick) then
  79.     if user then
  80.       umuteu(user)
  81.     else
  82.       umutec()
  83.     end
  84.   else
  85.     error("Access denied")
  86.   end
  87. end
  88.  
  89. function wladd(user)
  90.   if iswlisted(irc_nick) then
  91.     if iswlisted(user) then
  92.       npt(user.." is already whitelisted")
  93.     else
  94.       table.insert(accesswhitelist, user)
  95.       npt(user.." added to whitelist")
  96.     end
  97.   else
  98.     error("Access denied")
  99.   end
  100. end
  101.  
  102. local function getwlindex(user)
  103.   for k, v in ipairs(accesswhitelist) do
  104.     if v:lower() == user:lower() then
  105.       return k
  106.     end
  107.   end
  108.   return nil
  109. end
  110.  
  111. function wlrem(user)
  112.   if iswlisted(irc_nick) then
  113.     if user == irc_nick then
  114.       npt("You can't un-whitelist yourself")
  115.     elseif iswlisted(user) then
  116.       table.remove(accesswhitelist, getwlindex(user))
  117.       npt(user.." removed from whitelist")
  118.     else
  119.       npt(user.." is not whitelisted")
  120.     end
  121.   else
  122.     error("Access denied")
  123.   end
  124. end
  125.  
  126. --[[function hide(...)
  127.   local a = {...}
  128.   for k, v in a do
  129.     _G[a] = nil
  130.   end
  131. end
  132.  
  133. function irc_command(from, chan, cmd)
  134.   irc_nick = from
  135.   irc_channel = chan
  136.   if cmd == "mute" then mutec()
  137.   elseif cmd:sub(1, 5) == "mute " then mute(cmd:sub(6))
  138.   elseif cmd == "unmute" then mutec()
  139.   elseif cmd:sub(1, 7) == "unmute " then unmute(cmd:sub(8))
  140.   elseif cmd:sub(1, 6) == "wladd " then wladd(cmd:sub(7))
  141.   elseif cmd:sub(1, 6) == "wlrem " then wlrem(cmd:sub(7))
  142.   end
  143. end
  144.  
  145. function next(table, index)
  146.   while true do
  147.     k, v = nnxt(table, index)
  148.     if key == nil or not table.hide[k] then return k, v end
  149.   end
  150. end--]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement