Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[To activate the kitsunemod script run the following:
- !kitsunebot MOD.KitsuneMod="rXL3ZRYw"; MOD.Save(); MOD.Reload();
- ]]
- local domains = [[.ac.ad.ae.aero.af.ag.ai.al.am.an.ao.aq.ar.arpa.as.asia.at.au
- .aw.ax.az.ba.bb.bd.be.bf.bg.bh.bi.biz.bj.bm.bn.bo.br.bs.bt.bv.bw.by.bz.ca
- .cat.cc.cd.cf.cg.ch.ci.ck.cl.cm.cn.co.com.coop.cr.cs.cu.cv.cx.cy.cz.dd.de
- .dj.dk.dm.do.dz.ec.edu.ee.eg.eh.er.es.et.eu.fi.firm.fj.fk.fm.fo.fr.fx.ga
- .gb.gd.ge.gf.gh.gi.gl.gm.gn.gov.gp.gq.gr.gs.gt.gu.gw.gy.hk.hm.hn.hr.ht.hu
- .id.ie.il.im.in.info.int.io.iq.ir.is.it.je.jm.jo.jobs.jp.ke.kg.kh.ki.km.kn
- .kp.kr.kw.ky.kz.la.lb.lc.li.lk.lr.ls.lt.lu.lv.ly.ma.mc.md.me.mg.mh.mil.mk
- .ml.mm.mn.mo.mobi.mp.mq.mr.ms.mt.mu.museum.mv.mw.mx.my.mz.na.name.nato.nc
- .ne.net.nf.ng.ni.nl.no.nom.np.nr.nt.nu.nz.om.org.pa.pe.pf.pg.ph.pk.pl.pm
- .pn.post.pr.pro.ps.pt.pw.py.qa.re.ro.ru.rw.sa.sb.sc.sd.se.sg.sh.si.sj.sk
- .sl.sm.sn.so.sr.ss.st.store.su.sv.sy.sz.tc.td.tel.tf.tg.th.tj.tk.tl.tm.tn
- .to.tp.tr.travel.tt.tv.tw.tz.ua.ug.uk.um.us.uy.va.vc.ve.vg.vi.vn.vu.web.wf
- .ws.xxx.ye.yt.yu.za.zm.zr.zw]]
- local tlds = {}
- for tld in domains:gmatch'%w+' do
- tlds[tld] = true
- end
- local function IsURLBlackListed(prot, subd, tld, colon, port, slash, path)
- if ( prot and prot ~= "" ) or tlds[tld:lower()] then
- if type(MOD.URLWhiteList)~="table"then
- MOD.URLWhiteList = {};
- return true;
- end
- subd = subd:lower();
- subd = subd:gsub("www.","");
- subd = subd:sub(0,subd:len()-1);
- local website = subd.."."..tld;
- website = website:lower();
- if MOD.URLWhiteList[website] then
- return false;
- end
- return true;
- end
- return false;
- end
- local function GetHasBlacklistedURLs(msg)
- local urls = {};
- for pos, url, prot, subd, tld, colon, port, slash, path in msg:gmatch
- '()(([%w_.~!*:@&+$/?%%#-]-)(%w[-.%w]*%.)(%w+)(:?)(%d*)(/?)([%w_.~!*:@&+$/?%%#=-]*))'
- do
- if IsURLBlackListed(prot, subd, tld, colon, port, slash, path)then
- return true;
- end
- end
- return false;
- end
- local function IsUserWhitelisted(user)
- if UserStatus(user) == 2 then
- return true;
- elseif type(MOD.UserWhiteList)~="table"then
- MOD.UserWhiteList = {};
- return false;
- elseif MOD.UserWhiteList[user:lower()] then
- return true;
- else
- return false;
- end
- end
- local function IsBroadcaster(user)
- local channel = Channel():sub(2):lower();
- return channel == user:lower();
- end
- local function Join(user)
- end
- local function Leave(user)
- end
- local function Message(user, msg)
- if UserStatus("kitsunebot") == 2 then
- if IsUserWhitelisted(user) then
- return;
- elseif( GetHasBlacklistedURLs(msg) )then
- MOD.Timer("to_"..user,0,function() MOD.Timeout(user); end);
- print("@"..user.." purged link");
- return;
- end
- end
- end
- local function Tick(channel)
- end
- MOD = MOD or {};
- --These are called from the http://pastebin.com/y68mc6pM script
- MOD.EventJoin = Join;
- MOD.EventLeave = Leave;
- MOD.EventMsg = Message;
- MOD.EventTick = Tick;
- --Commands
- MOD.AddCom("reg",function(msg,usr,chan)
- if not msg or msg == "" or UserStatus(usr)~=2 then
- return;
- end
- if type(MOD.UserWhiteList)~="table"then
- MOD.UserWhiteList = {};
- end
- MOD.UserWhiteList[msg:lower()]=true;
- print("@"..usr.. " user " .. msg .. " has been added to the regulars");
- MOD.Save();
- end);
- MOD.AddCom("unreg",function(msg,usr,chan)
- if not msg or msg == "" or UserStatus(usr)~=2 then
- return;
- end
- if type(MOD.UserWhiteList)~="table"then
- MOD.UserWhiteList = {};
- end
- MOD.UserWhiteList[msg:lower()]=nil;
- print("@"..usr.. " user " .. msg .. " has been removed from the regulars");
- MOD.Save();
- end);
- MOD.AddCom("regurl",function(msg,usr,chan)
- if not msg or msg == "" or UserStatus(usr)~=2 then
- return;
- end
- if type(MOD.URLWhiteList)~="table"then
- MOD.URLWhiteList = {};
- end
- if not GetHasBlacklistedURLs(msg) then
- print("URL already whitelisted or the format is invalid. Format should be: google.com");
- return;
- end
- local pos, url, prot, subd, tld, colon, port, slash, path = msg:match('()(([%w_.~!*:@&+$/?%%#-]-)(%w[-.%w]*%.)(%w+)(:?)(%d*)(/?)([%w_.~!*:@&+$/?%%#=-]*))');
- subd = subd:lower();
- subd = subd:gsub("www.","");
- subd = subd:sub(0,subd:len()-1);
- local website = subd.."."..tld;
- MOD.URLWhiteList[website:lower()]=true;
- print("@"..usr.. " URL " .. msg .. " has been whitelisted");
- MOD.Save();
- end);
- MOD.AddCom("unregurl",function(msg,usr,chan)
- if not msg or msg == "" or UserStatus(usr)~=2 then
- return;
- end
- if type(MOD.URLWhiteList)~="table"then
- MOD.URLWhiteList = {};
- end
- local pos, url, prot, subd, tld, colon, port, slash, path = msg:match('()(([%w_.~!*:@&+$/?%%#-]-)(%w[-.%w]*%.)(%w+)(:?)(%d*)(/?)([%w_.~!*:@&+$/?%%#=-]*))');
- subd = subd:lower();
- subd = subd:gsub("www.","");
- subd = subd:sub(0,subd:len()-1);
- local website = subd.."."..tld;
- MOD.URLWhiteList[website:lower()]=nil;
- print("@"..usr.. " URL " .. msg .. " has been removed from the whitelist");
- MOD.Save();
- end);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement