Advertisement
Terrah

Kitsunemod

Nov 14th, 2014
1,493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[To activate the kitsunemod script run the following:
  2.     !kitsunebot MOD.KitsuneMod="rXL3ZRYw"; MOD.Save(); MOD.Reload();
  3. ]]
  4.  
  5. local domains = [[.ac.ad.ae.aero.af.ag.ai.al.am.an.ao.aq.ar.arpa.as.asia.at.au
  6.    .aw.ax.az.ba.bb.bd.be.bf.bg.bh.bi.biz.bj.bm.bn.bo.br.bs.bt.bv.bw.by.bz.ca
  7.    .cat.cc.cd.cf.cg.ch.ci.ck.cl.cm.cn.co.com.coop.cr.cs.cu.cv.cx.cy.cz.dd.de
  8.    .dj.dk.dm.do.dz.ec.edu.ee.eg.eh.er.es.et.eu.fi.firm.fj.fk.fm.fo.fr.fx.ga
  9.    .gb.gd.ge.gf.gh.gi.gl.gm.gn.gov.gp.gq.gr.gs.gt.gu.gw.gy.hk.hm.hn.hr.ht.hu
  10.    .id.ie.il.im.in.info.int.io.iq.ir.is.it.je.jm.jo.jobs.jp.ke.kg.kh.ki.km.kn
  11.    .kp.kr.kw.ky.kz.la.lb.lc.li.lk.lr.ls.lt.lu.lv.ly.ma.mc.md.me.mg.mh.mil.mk
  12.    .ml.mm.mn.mo.mobi.mp.mq.mr.ms.mt.mu.museum.mv.mw.mx.my.mz.na.name.nato.nc
  13.    .ne.net.nf.ng.ni.nl.no.nom.np.nr.nt.nu.nz.om.org.pa.pe.pf.pg.ph.pk.pl.pm
  14.    .pn.post.pr.pro.ps.pt.pw.py.qa.re.ro.ru.rw.sa.sb.sc.sd.se.sg.sh.si.sj.sk
  15.    .sl.sm.sn.so.sr.ss.st.store.su.sv.sy.sz.tc.td.tel.tf.tg.th.tj.tk.tl.tm.tn
  16.    .to.tp.tr.travel.tt.tv.tw.tz.ua.ug.uk.um.us.uy.va.vc.ve.vg.vi.vn.vu.web.wf
  17.    .ws.xxx.ye.yt.yu.za.zm.zr.zw]]
  18. local tlds = {}
  19. for tld in domains:gmatch'%w+' do
  20.    tlds[tld] = true
  21. end
  22.  
  23. local function IsURLBlackListed(prot, subd, tld, colon, port, slash, path)
  24.  
  25.     if ( prot and prot ~= "" ) or tlds[tld:lower()] then
  26.  
  27.         if type(MOD.URLWhiteList)~="table"then
  28.             MOD.URLWhiteList = {};
  29.             return true;
  30.         end
  31.  
  32.         subd = subd:lower();
  33.         subd = subd:gsub("www.","");
  34.         subd = subd:sub(0,subd:len()-1);
  35.  
  36.         local website = subd.."."..tld;
  37.  
  38.         website = website:lower();
  39.  
  40.         if MOD.URLWhiteList[website] then
  41.             return false;
  42.         end
  43.  
  44.         return true;
  45.     end
  46.  
  47.     return false;
  48. end
  49.  
  50. local function GetHasBlacklistedURLs(msg)
  51.  
  52.     local urls = {};
  53.  
  54.     for pos, url, prot, subd, tld, colon, port, slash, path in msg:gmatch
  55.        '()(([%w_.~!*:@&+$/?%%#-]-)(%w[-.%w]*%.)(%w+)(:?)(%d*)(/?)([%w_.~!*:@&+$/?%%#=-]*))'
  56.     do
  57.  
  58.         if IsURLBlackListed(prot, subd, tld, colon, port, slash, path)then
  59.             return true;
  60.         end
  61.     end
  62.  
  63.     return false;
  64. end
  65.  
  66. local function IsUserWhitelisted(user)
  67.  
  68.     if UserStatus(user) == 2 then
  69.         return true;
  70.     elseif type(MOD.UserWhiteList)~="table"then
  71.         MOD.UserWhiteList = {};
  72.         return false;
  73.     elseif MOD.UserWhiteList[user:lower()] then
  74.         return true;
  75.     else
  76.         return false;
  77.     end
  78. end
  79.  
  80. local function IsBroadcaster(user)
  81.     local channel = Channel():sub(2):lower();
  82.     return channel  == user:lower();
  83. end
  84.  
  85.  
  86. local function Join(user)
  87.  
  88. end
  89.  
  90. local function Leave(user)
  91.  
  92. end
  93.  
  94. local function Message(user, msg)
  95.  
  96.     if UserStatus("kitsunebot") == 2 then
  97.         if IsUserWhitelisted(user) then
  98.             return;
  99.         elseif( GetHasBlacklistedURLs(msg) )then
  100.             MOD.Timer("to_"..user,0,function() MOD.Timeout(user); end);
  101.             print("@"..user.." purged link");
  102.             return;
  103.         end
  104.     end
  105. end
  106.  
  107. local function Tick(channel)
  108.  
  109. end
  110.  
  111. MOD = MOD or {};
  112. --These are called from the http://pastebin.com/y68mc6pM script
  113. MOD.EventJoin = Join;
  114. MOD.EventLeave = Leave;
  115. MOD.EventMsg = Message;
  116. MOD.EventTick = Tick;
  117.  
  118. --Commands
  119. MOD.AddCom("reg",function(msg,usr,chan)
  120.  
  121.     if not msg or msg == "" or UserStatus(usr)~=2 then
  122.         return;
  123.     end
  124.  
  125.     if type(MOD.UserWhiteList)~="table"then
  126.         MOD.UserWhiteList = {};
  127.     end
  128.  
  129.     MOD.UserWhiteList[msg:lower()]=true;
  130.  
  131.     print("@"..usr.. " user " .. msg .. " has been added to the regulars");
  132.  
  133.     MOD.Save();
  134.  
  135. end);
  136.  
  137. MOD.AddCom("unreg",function(msg,usr,chan)
  138.  
  139.     if not msg or msg == "" or UserStatus(usr)~=2 then
  140.         return;
  141.     end
  142.  
  143.     if type(MOD.UserWhiteList)~="table"then
  144.         MOD.UserWhiteList = {};
  145.     end
  146.  
  147.     MOD.UserWhiteList[msg:lower()]=nil;
  148.  
  149.     print("@"..usr.. " user " .. msg .. " has been removed from the regulars");
  150.  
  151.     MOD.Save();
  152.  
  153. end);
  154.  
  155. MOD.AddCom("regurl",function(msg,usr,chan)
  156.  
  157.     if not msg or msg == "" or UserStatus(usr)~=2 then
  158.         return;
  159.     end
  160.  
  161.     if type(MOD.URLWhiteList)~="table"then
  162.         MOD.URLWhiteList = {};
  163.     end
  164.  
  165.     if not GetHasBlacklistedURLs(msg) then
  166.         print("URL already whitelisted or the format is invalid. Format should be: google.com");
  167.         return;
  168.     end
  169.  
  170.     local pos, url, prot, subd, tld, colon, port, slash, path = msg:match('()(([%w_.~!*:@&+$/?%%#-]-)(%w[-.%w]*%.)(%w+)(:?)(%d*)(/?)([%w_.~!*:@&+$/?%%#=-]*))');
  171.  
  172.     subd = subd:lower();
  173.     subd = subd:gsub("www.","");
  174.     subd = subd:sub(0,subd:len()-1);
  175.  
  176.     local website = subd.."."..tld;
  177.  
  178.     MOD.URLWhiteList[website:lower()]=true;
  179.  
  180.     print("@"..usr.. " URL " .. msg .. " has been whitelisted");
  181.  
  182.     MOD.Save();
  183.  
  184. end);
  185.  
  186. MOD.AddCom("unregurl",function(msg,usr,chan)
  187.  
  188.     if not msg or msg == "" or UserStatus(usr)~=2 then
  189.         return;
  190.     end
  191.  
  192.     if type(MOD.URLWhiteList)~="table"then
  193.         MOD.URLWhiteList = {};
  194.     end
  195.  
  196.     local pos, url, prot, subd, tld, colon, port, slash, path = msg:match('()(([%w_.~!*:@&+$/?%%#-]-)(%w[-.%w]*%.)(%w+)(:?)(%d*)(/?)([%w_.~!*:@&+$/?%%#=-]*))');
  197.  
  198.     subd = subd:lower();
  199.     subd = subd:gsub("www.","");
  200.     subd = subd:sub(0,subd:len()-1);
  201.  
  202.     local website = subd.."."..tld;
  203.  
  204.     MOD.URLWhiteList[website:lower()]=nil;
  205.  
  206.     print("@"..usr.. " URL " .. msg .. " has been removed from the whitelist");
  207.  
  208.     MOD.Save();
  209.  
  210. end);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement