| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875 |
- ##########################################################
- #
- # BLackToolS
- # Modules TCL
- #
- # BLaCkShaDoW ProductionS
- ##########################################################
- set black(gag_file) "scripts/BlackTools/FILES/$username.gag.txt"
- if {![file exists $black(gag_file)]} {
- set file [open $black(gag_file) w]
- close $file
- }
- proc check:stats:entries {oldpath newpath} {
- global botnick
- if {![file exists $newpath]} {
- set file [open $newpath w]
- close $file
- }
- if {[file exists $oldpath]} {
- set file [open $oldpath r]
- set w [read -nonewline $file]
- close $file
- if {$w != ""} {
- set data [split $w "\n"]
- foreach entry $data {
- set file [open $newpath a]
- puts $file "$entry"
- close $file
- }
- set file [open $oldpath w]
- close $file
- }
- }
- }
- set old_stats_dir "$username.stats.db"
- set new_stats_dir "scripts/BlackTools/FILES/$username.stats.txt"
-
- check:stats:entries $old_stats_dir $new_stats_dir
-
- proc check:away {oldpath newpath} {
- global black
- if {![file exists $newpath]} {
- set file [open $newpath w]
- close $file
- }
- if {[file exists $oldpath]} {
- set file [open $oldpath r]
- set w [gets $file]
- close $file
- if {$w != ""} {
- set file [open $newpath a]
- puts $file "$w"
- close $file
- }
- set file [open $oldpath w]
- close $file
- }
- }
- set old_away_dir "$username.away.txt"
- set new_away_dir "scripts/BlackTools/FILES/$username.away.txt"
-
- check:away $old_away_dir $new_away_dir
- proc check:badchan:entries {chan oldpath newpath} {
- global botnick
- if {![file exists $newpath]} {
- set file [open $newpath w]
- close $file
- }
- if {[file exists $oldpath]} {
- set file [open $oldpath r]
- set w [read -nonewline $file]
- close $file
- if {$w != ""} {
- set data [split $w "\n"]
- foreach entry $data {
- set file [open $newpath a]
- puts $file "$chan $entry NONE"
- close $file
- }
- set file [open $oldpath w]
- close $file
- }
- }
- }
- proc check:module {oldpath newpath} {
- global botnick
- if {![file exists $newpath]} {
- set file [open $newpath w]
- close $file
- }
- if {[file exists $oldpath]} {
- set file [open $oldpath r]
- set w [read -nonewline $file]
- close $file
- if {$w != ""} {
- set data [split $w "\n"]
- foreach entry $data {
- set file [open $newpath a]
- puts $file "$entry"
- close $file
- }
- set file [open $oldpath w]
- close $file
- }
- }
- }
- set old_status_dir "$username.status.txt"
- set new_status_dir "scripts/BlackTools/FILES/$username.status.txt"
-
- check:module $old_status_dir $new_status_dir
- set old_seen_dir "$username.Seen.db"
- set new_seen_dir "scripts/BlackTools/FILES/$username.Seen.db"
-
- check:module $old_seen_dir $new_seen_dir
- proc check:greet:entries {chan oldpath newpath} {
- global botnick
- if {![file exists $newpath]} {
- set file [open $newpath w]
- close $file
- }
- if {[file exists $oldpath]} {
- set file [open $oldpath r]
- set w [read -nonewline $file]
- close $file
- if {$w != ""} {
- set data [split $w "\n"]
- foreach entry $data {
- set file [open $newpath a]
- puts $file "$chan 0 $entry"
- close $file
- }
- set file [open $oldpath w]
- close $file
- }
- }
- }
- proc check:anunt:entries {chan oldpath newpath} {
- global botnick
- if {![file exists $newpath]} {
- set file [open $newpath w]
- close $file
- }
- if {[file exists $oldpath]} {
- set file [open $oldpath r]
- set w [read -nonewline $file]
- close $file
- if {$w != ""} {
- set data [split $w "\n"]
- foreach entry $data {
- set file [open $newpath a]
- puts $file "$chan $entry"
- close $file
- }
- set file [open $oldpath w]
- close $file
- }
- }
- }
- proc check:broadcast:entries {oldpath newpath} {
- global botnick
- if {![file exists $newpath]} {
- set file [open $newpath w]
- close $file
- }
- if {[file exists $oldpath]} {
- set file [open $oldpath r]
- set w [read -nonewline $file]
- close $file
- if {$w != ""} {
- set data [split $w "\n"]
- foreach entry $data {
- set file [open $newpath a]
- puts $file "$entry"
- close $file
- }
- set file [open $oldpath w]
- close $file
- }
- }
- }
- set old_broadcast_dir "logs/broadcast.txt"
- set new_broadcast_dir "scripts/BlackTools/FILES/$username.autobroadcast.txt"
- check:broadcast:entries $old_broadcast_dir $new_broadcast_dir
- foreach chan [join [channels]] {
- set old_greet_dir "logs/greet($chan).txt"
- set new_greet_dir "scripts/BlackTools/FILES/$username.greets.txt"
- set old_leave_dir "logs/leave($chan).txt"
- set new_leave_dir "scripts/BlackTools/FILES/$username.leave.txt"
-
- set old_badchan_dir "logs/badchan($chan).txt"
- set new_badchan_dir "scripts/BlackTools/FILES/$username.badchannels.txt"
-
- set old_anunt_dir "logs/anunt($chan).txt"
- set new_anunt_dir "scripts/BlackTools/FILES/$username.announce.txt"
-
- set old_topic_dir "logs/topic($chan).txt"
- set new_topic_dir "scripts/BlackTools/FILES/$username.topic.txt"
-
- check:greet:entries $chan $old_leave_dir $new_greet_dir
- check:greet:entries $chan $old_leave_dir $new_leave_dir
- check:badchan:entries $chan $old_badchan_dir $new_badchan_dir
- check:anunt:entries $chan $old_anunt_dir $new_anunt_dir
- check:anunt:entries $chan $old_topic_dir $new_topic_dir
- }
- if {![info exists anuntpublic:show_running]} {
- timer $black(anunttime) anuntpublic:show
- set anuntpublic:show_running 1
- }
- if {![info exists times_topic_running]} {
- timer $black(topic_time) times_topic
- set times_topic_running 1
- }
- if {![info exists antibotidle:module_running]} {
- set sdir "scripts/BlackTools/FILES/$username.status.txt"
- set file [open $sdir "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
- if {$data != ""} {
- foreach line $data {
- set type [lindex [split $line] 0]
- set stats [lindex [split $line] 1]
- if {($type == "antibotidle:module") && ($stats == "ON")} {
- timer $black(noidlemax) antibotidle:module
- set antibotidle:module_running 1
- }
- }
- }
- }
- if {![info exists broadcastpublic:show_running]} {
- set sdir "scripts/BlackTools/FILES/$username.status.txt"
- set file [open $sdir "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
- if {$data != ""} {
- foreach line $data {
- set type [lindex [split $line] 0]
- set stats [lindex [split $line] 1]
- if {($type == "broadcastpublic:show") && ($stats == "ON")} {
- timer $black(bttime) broadcastpublic:show
- set broadcastpublic:show_running 1
- }
- }
- }
- }
- proc blacktools:tell:prv {nick host hand type arg} {
- global botnick black
- set char(p) [lindex $black(cmdchar) 0]
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- set replace(%botnick%) $botnick
- set replace(%char%) $char(p)
- set replace(%msg%) [lrange [split $arg] 0 end]
- set replace(%msg.1%) [lindex [split $arg] 0]
- set replace(%msg.2%) [lindex [split $arg] 1]
- set replace(%msg.3%) [lindex [split $arg] 2]
- set replace(%msg.4%) [lrange [split $arg] 1 end]
- set getlang [string tolower [getuser $hand XTRA OUTPUT_LANG]]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
- if {[info exists black(say.$getlang.$type)]} {
- set reply [string map [array get replace] $black(say.$getlang.$type)]
- puthelp "PRIVMSG $nick :$reply"
- }
- }
- proc blacktools:tell {nick host hand chan chan1 type arg} {
- global black botnick
- set char(p) [lindex $black(cmdchar) 0]
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- set replace(%botnick%) $botnick
- set replace(%char%) $char(p)
- set replace(%chan%) $chan
- set replace(%msg%) [join [lrange $arg 0 end]]
- set replace(%msg.set%) [join [lrange [split $arg] 1 end]]
- set replace(%msg.1%) [lindex $arg 0]
- set replace(%msg.2%) [lindex $arg 1]
- set replace(%msg.3%) [lindex $arg 2]
- set replace(%msg.4%) [lindex $arg 3]
- set replace(%msg.5%) [lrange $arg 4 end]
- set replace(%msg.6%) [lrange $arg 3 end]
- set replace(%msg.7%) [lrange $arg 2 end]
- set replace(%msg.8%) [join [lrange $arg 1 end]]
- set getlang [string tolower [getuser $hand XTRA OUTPUT_LANG]]
- set getmethod [getuser $hand XTRA OUTPUT_TYPE]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
- if {$getmethod == ""} { set getmethod "1" }
- if {[info exists black(say.$getlang.$type)]} {
- set reply [string map [array get replace] $black(say.$getlang.$type)]
- if {$getmethod == "1"} {
- putserv "NOTICE $nick :$reply"
- } else {
- putserv "PRIVMSG $chan1 :$reply"
- }
- }
- }
- ######################## Flood Protection #######################
- proc flood:join:protection {nick host hand chan} {
- global black count
- if {[channel get $chan greet] || [channel get $chan count] || [channel get $chan antijoinflood]} {
- set joinflood [channel get $chan joinflood]
- if {$joinflood == ""} {set joinflood "4:5"}
- set number [scan $joinflood %\[^:\]]
- set time [scan $joinflood %*\[^:\]:%s]
-
- foreach tmr [utimers] {
- if {[string match "*count(flood:join:$chan)*" [join [lindex $tmr 1]]]} {
- killutimer [lindex $tmr 2]
- }
- }
- if {[info exists black(turnOnFlood:$chan)]} {
- return
- }
- if {![info exists count(flood:join:$chan)]} {
- set count(flood:join:$chan) 0
- }
- incr count(flood:join:$chan)
- utimer $time [list remove:flood:join $chan]
- if {$count(flood:join:$chan) >= $number} {
- set black(turnOnFlood:$chan) 1
- utimer 60 [list unset black(turnOnFlood:$chan)]
- return
- }
- }
- }
- proc remove:flood:join {chan} {
- global count
- if {[info exists count(flood:join:$chan)]} {
- unset count(flood:join:$chan)
- }
- }
- ########################### TCL #################################
- proc tclpublic {nick host hand chan arg} {
- global black
- set type 0
- set chan1 "$chan"
- set the_script [lindex [split $arg] 1]
- set who [lindex [split $arg] 0]
- tcl:process $nick $host $hand $chan $chan1 $type $the_script $who
- }
- proc tcl:process {nick host hand chan chan1 type the_script who} {
- global black
-
- if {($who == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 tcl.15 none
- return
- }
- if {($who == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 tcl.16 none
- return
- }
- switch $who {
- list {
-
- set scripts ""
- set file [open "$black(configname)" r]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- foreach line $data {
- if {[string match -nocase "source $black(dirname)/*" $line]} {
- set the_split [split $line "/"]
- set the_script [lindex $the_split 1]
- lappend scripts $the_script
- }
- }
- blacktools:tell $nick $host $hand $chan $chan1 tcl.1 none
- foreach txt [wordwrap [join $scripts ", "] 250 ,] {
- blacktools:tell $nick $host $hand $chan $chan1 tcl.17 $txt
- }
- }
-
- load {
- if {$the_script == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 tcl.2 none
- return
- }
- set black(tcl_load) [catch {source "$black(dirname)/$the_script"} black(tcl_load_error)]
-
- if {$black(tcl_load) == "1"} {
- blacktools:tell $nick $host $hand $chan $chan1 tcl.3 "$the_script [split $black(tcl_load_error)]"
- return
- }
- set file [open "$black(configname)" r]
- set w [read -nonewline $file]
- close $file
- set counter -1
- set data [split $w "\n"]
- set tcl_position -1
- set found_it 0
- foreach line $data {
- if {[string match -nocase "source $black(dirname)/*" $line]} {
- set the_split [split $line "/"]
- set script [lindex $the_split 1]
- if {[string equal -nocase $script $the_script]} {
- set found_it 1
- }
- }
- }
- if {$found_it == 1} {
- blacktools:tell $nick $host $hand $chan $chan1 tcl.4 $the_script
- return
- }
- set file [open "$black(configname)" a]
- puts $file "source $black(dirname)/$the_script"
- close $file
- rehash
- blacktools:tell $nick $host $hand $chan $chan1 tcl.5 $the_script
- }
- unload {
- if {$the_script == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 tcl.6 $the_script
- return
- }
- if {[string match "*BlackTools*" $the_script]} {
- blacktools:tell $nick $host $hand $chan $chan1 tcl.18 none
- return
- }
- set file [open "$black(configname)" r]
- set w [read -nonewline $file]
- close $file
- set counter -1
- set data [split $w "\n"]
- set tcl_position -1
- set found_it 0
- foreach line $data {
- set counter [expr $counter + 1]
- if {[string match -nocase "*source $black(dirname)/*" $line]} {
- set the_split [split $line "/"]
- set script [lindex $the_split 1]
- if {[string equal -nocase $script $the_script]} {
- set found_it 1
- set tcl_position $counter
- }
- }
- }
- if {$found_it == 0} {
- blacktools:tell $nick $host $hand $chan $chan1 tcl.7 $the_script
- return
- }
- set delete [lreplace $data $tcl_position $tcl_position]
- set file [open "$black(configname)" "w"]
- puts $file [join $delete "\n"]
- close $file
- rehash
- blacktools:tell $nick $host $hand $chan $chan1 tcl.8 $the_script
- }
- all {
- set the_files [glob -directory $black(dirname) "*.tcl"]
- set counter 0
- set current_tcl ""
-
- foreach file $the_files {
- set counter [expr $counter + 1]
- }
- if {$counter > 30} {
- blacktools:tell $nick $host $hand $chan $chan1 tcl.9 $counter
- } else { blacktools:tell $nick $host $hand $chan $chan1 tcl.10 $counter
- }
- set counter 0
- foreach file $the_files {
- set counter [expr $counter + 1]
- set split_file [split $file "/"]
- set the_file [lindex $split_file 1]
- set status [check:if:load $the_file]
- if {$counter < 30} {
- if {$status == "1"} {
- lappend current_tcl "\002$the_file\002"
- } else {
- lappend current_tcl $the_file
- }
- }
- }
- foreach txt [wordwrap [join $current_tcl ", "] 250 ,] {
- blacktools:tell $nick $host $hand $chan $chan1 tcl.17 $txt
- }
- }
- info {
- if {$the_script == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 tcl.11 none
- return
- }
- set status_valid [check:if:valid $the_script]
- set status [check:if:load $the_script]
- if {$status_valid == "0"} {
- blacktools:tell $nick $host $hand $chan $chan1 tcl.12 $the_script
- return
- }
- if {$status == "0"} {
- blacktools:tell $nick $host $hand $chan $chan1 tcl.13 $the_script
- } else {
- blacktools:tell $nick $host $hand $chan $chan1 tcl.14 $the_script
- }
- }
- default {
- blacktools:tell $nick $host $hand $chan $chan1 tcl.15 none
- }
- }
-
- }
- proc check:if:valid {tcl} {
- global black
- set the_files [glob -directory $black(dirname) "*.tcl"]
- foreach file $the_files {
- set split_file [split $file "/"]
- set the_file [lindex $split_file 1]
- if {[string equal -nocase $tcl $the_file]} {
- return 1
- }
- }
- return 0
- }
- proc check:if:load {tcl} {
- global black
- set file [open "$black(configname)" r]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set found_it 0
- foreach line $data {
- if {[string match -nocase "source $black(dirname)/*" $line]} {
- set the_split [split $line "/"]
- set script [lindex $the_split 1]
- if {[string equal -nocase $script $tcl]} {
- set found_it 1
- }
- }
- }
- if {$found_it == 1} {
- return 1
- } else {
- return 0
- }
- }
- ########################## Login ###############################
- proc loginpublic {my} {
- global botnick black
- if {[info exists black(logged)]} {
- unset black(logged)
- }
- if {[info exists black(notlogged)]} {
- unset black(notlogged)
- }
- putquick "$black(login)"
- putquick "MODE $botnick :$black(xmod)"
- }
- proc publiclogin:Cmd {nick host hand chan arg} {
- global botnick black
- putquick "$black(login)"
- putquick "MODE $botnick :$black(xmod)"
- blacktools:tell:prv $nick $host $hand login.1 $black(chanserv)
- }
- ################################# reban ################################
- proc rebanpublic {nick host hand chan} {
- global black
- if {[channel get $chan xban]} {
- set host "$nick![getchanhost $nick $chan]"
- set getxtime [channel get $chan xbantime]
- set getxlevel [channel get $chan xbanlevel]
- if {$getxlevel == "0"} { set getxlevel "100" }
- if {$getxtime == "0"} { set getxtime "1" }
- foreach ban [banlist $chan] {
- set reason [lindex $ban 1]
- if {[string match -nocase [string tolower [lindex $ban 0]] $host]} {
- putquick "PRIVMSG $black(chanserv) :ban $chan [lindex $ban 0] $getxtime $getxlevel $reason"
- }
- }
- }
- }
- ################################# XTOOLS ################################
- proc toolspublic {chan type} {
- global botnick black
- if {![channel get $chan xtools]} {
- return
- }
- if {$type == "op"} {
- if {![onchan "$black(chanserv)" $chan] && ![botisop $chan]} {
- return
- }
- putquick "PRIVMSG $black(chanserv) :unban $chan $botnick"
- putquick "PRIVMSG $black(chanserv) :op $chan $botnick"
- return
- }
- if {$type == "unban"} {
- putquick "PRIVMSG $black(chanserv) :unban $chan $botnick"
- return
- }
- if {$type == "invite" || $type == "limit"} {
- putquick "PRIVMSG $black(chanserv) :invite $chan $botnick"
- return
- }
- if {$type == "key"} {
- putquick "PRIVMSG $black(chanserv) :invite $chan $botnick"
- return
- }
- }
- ################################# Key Need ######################################
- proc keyneed {chan type} {
- global black
- if {![validchan $chan]} {
- return
- }
- if {$type == "key"} {
- if {![regexp {k} [channel get $chan chanmode]]} {
- return
- } else {
- set the_key [lindex [split [channel get $chan chanmode]] 1]
- if {$the_key == ""} { return }
- putserv "JOIN $chan :$the_key"
- }
- }
- }
- ################################# Clone Scan ###################################
- proc scannerpublic {nick host hand chan arg} {
- global black count
- set c [lindex [split $arg] 0]
- set type 0
- set chan1 "$chan"
- if {[regexp {^[&#]} $c] && [matchattr $hand nm|- $chan]} {
- set chan "$c"
- }
- scanner:process $nick $host $hand $chan $chan1
- }
- proc scanner:process {nick host hand chan chan1} {
- global botnick black
- array set clones [list]
- if {![validchan $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
- return
- }
- if {![onchan $botnick $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
- return
- }
- blacktools:tell $nick $host $hand $chan $chan1 clonescan.4 none
-
- if {[channel get $chan clonescan-maxclone] == 0} {
- set maxclone $black(maxclone)
- } else { set maxclone [channel get $chan clonescan-maxclone] }
-
- if {!($maxclone >= "2")} { return }
-
- foreach user [chanlist $chan] {
- set host [string tolower [lindex [split [getchanhost $user $chan] @] 1]]
- if {![string match "*.undernet.org*" $host]} {
- if {![info exists c($host:$chan)]} {
- set c($host:$chan) 0
- }
- set c($host:$chan) [expr $c($host:$chan) +1]
- lappend clones($user) $host
- if {$c($host:$chan) >= $maxclone} {
- foreach clon [lsort -unique [array names clones]] {
- set hosts [string tolower [lindex [split [getchanhost $clon $chan] @] 1]]
- if {$host == $hosts} {
- lappend clona($host) [join $clon " , "]
- }
- }
- blacktools:tell $nick $host $hand $chan $chan1 clonescan.1 "$c($host:$chan) $host [lsort -unique $clona($host)]"
- }
- }
- }
- utimer 3 [list blacktools:tell $nick $host $hand $chan $chan1 clonescan.2 none]
- }
- proc clonescanner {minute hour day month year} {
- global black botnick
- foreach chan [channels] {
- set replace(%chan%) $chan
- if {[channel get $chan clonescan]} {
- set getlang [string tolower [channel get $chan lang]]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
- if {[channel get $chan clonescan-maxclone] == 0} {
- set maxclone $black(maxclone)
- } else { set maxclone [channel get $chan clonescan-maxclone] }
- if {$maxclone < "2"} { return }
- putlog "Scaning for clones on $chan.."
- foreach user [chanlist $chan] {
- set host [string tolower [lindex [split [getchanhost $user $chan] @] 1]]
- set replace(%host%) $host
- if {![info exists c($host:$chan)]} {
- set c($host:$chan) 0
- }
- array set clones [list]
- if {![string match "*.undernet.org*" $host]} {
- set c($host:$chan) [expr $c($host:$chan) +1]
- lappend clones($user) $host
- if {$c($host:$chan) >= $maxclone} {
- foreach clon [array names clones] {
- set hosts [string tolower [lindex [split [getchanhost $clon $chan] @] 1]]
- if {$host == $hosts} {
- lappend clona($host) [join $clon " , "]
- }
- }
- set replace(%num%) $c($host:$chan)
- set replace(%clone%) [lsort -unique $clona($host)]
- if {[channel get $chan clonescan-action] == "" || [string equal -nocase [channel get $chan clonescan-action] "message"]} {
- putserv "NOTICE @$chan :[string map [array get replace] $black(say.$getlang.clonescan.3)]"
- } else {
- set banmask "*!*@$host"
- if {[channel get $chan clonescan-bantime] == 0} {
- set bantime $black(clonebtime)
- } else { set bantime [channel get $chan clonescan-bantime] }
- set reason [channel get $chan clonescan-banreason]
- if {$reason == ""} {
- set reason [string map [array get replace] [string map [array get replace] $black(say.$getlang.clonescan.5)]]
- }
- blacktools:banner:2 $banmask $botnick $chan $reason $bantime
- }
- }
- }
- }
- }
- }
- }
- ################################### gag ###############################
- proc gag:process {gagger time reason nick hand host chan chan1 type} {
- global botnick black
- set char(p) [lindex $black(cmdchar) 0]
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- set handle [nick2hand $gagger]
- if {![validchan $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
- return
- }
- if {![onchan $botnick $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
- return
- }
- if {[matchattr $hand -|q $chan]} { blacktools:tell $nick $host $hand $chan $chan1 gl.suspend none
- return
- }
- if {[matchattr $hand nm|- $chan]} {
- if {($gagger == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 gag.1 none
- return
- }
- if {($gagger == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 gag.2 none
- return
- }
- }
- if {($gagger == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 gag.3 none
- return
- }
- if {($gagger == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 gag.4 none
- return
- }
- if {[matchattr $handle $black(exceptflags) $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.noban none
- return
- }
- if {[string equal -nocase $gagger "-list"]} {
- set counter "0"
- set file [open $black(gag_file) "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
-
- if {$database == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 gag.7 none
- blacktools:tell $nick $host $hand $chan $chan1 gag.8 none
- return
- }
- foreach line $data {
- set counter [expr $counter +1]
- set hostentry [lindex [split $line] 1]
- set chanentry [lindex [split $line] 0]
- set timeentry [lindex [split $line] 2]
- set reason [join [lrange [split $line] 3 end]]
- blacktools:tell $nick $host $hand $chan $chan1 gag.7 none
- blacktools:tell $nick $host $hand $chan $chan1 gag.9 "$counter $hostentry [duration [expr $timeentry - [unixtime]]]"
- blacktools:tell $nick $host $hand $chan $chan1 gag.14 "$reason"
- }
- return
- }
- if {[isbotnick $gagger]} {
- return
- }
- if {![botisop $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.noop none
- return
- }
- if {$reason == ""} {
- set reason [channel get $chan gag-reason]
- if {$reason == ""} {
- set getlang [string tolower [channel get $chan lang]]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
- set reason $black(say.$getlang.gag.6)
- }
- }
- if {[isvoice $gagger $chan]} {
- putquick "MODE $chan -v $gagger"
- }
- if {[isop $gagger $chan]} {
- blacktools:tell $gagger $host $hand $chan $chan1 gag.12 "$gagger"
- return
- }
- if {[onchan $gagger $chan]} {
- set mask *!*@[lindex [split [getchanhost $gagger $chan] "@"] 1]
- } else { blacktools:tell $nick $host $hand $chan $chan1 gl.usernotonchan "$gagger"
- return
- }
- set getlang [string tolower [channel get $chan lang]]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
-
- set replace(%chan%) $chan
- set replace(%time%) $time
- set replace(%gagger%) $gagger
- set gag_user_message [string map [array get replace] $black(say.$getlang.gag.10)]
- set gag_chan_message [string map [array get replace] $black(say.$getlang.gag.11)]
-
- putquick "PRIVMSG $chan :$gag_chan_message"
- putquick "PRIVMSG $gagger :$gag_user_message"
- putquick "MODE $chan +b $mask"
-
- set seconds [expr $time * 60]
- set gag_time "[expr [unixtime] + $seconds]"
- set gag_act "$chan $mask $gag_time $reason"
- set counter "0"
- set file [open $black(gag_file) "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
-
- foreach line $data {
- set counter [expr $counter +1]
- set hostentry [lindex [split $line] 1]
- set chanentry [lindex [split $line] 0]
- set timeentry [lindex [split $line] 2]
- if {[string match -nocase $mask $hostentry] && [string match -nocase $chanentry $chan]} {
- blacktools:tell $gagger $host $hand $chan $chan1 gag.13 "$gagger $mask"
- if {$line != ""} {
- set counter [expr $counter -1]
- set delete [lreplace $data $counter $counter]
- set files [open $black(gag_file) "w"]
- puts $files [join $delete "\n"]
- close $files
- }
- }
- }
- set file [open $black(gag_file) "r"]
- set data [read -nonewline $file]
- close $file
- if {$data == ""} {
- set files [open $black(gag_file) "w"]
- close $files
- }
- set file [open $black(gag_file) "a"]
- puts $file "$gag_act"
- close $file
- }
- proc gagpublic {nick host hand chan arg} {
- global black
- set gagger [lindex [split $arg] 0]
- set time [lindex [split $arg] 1]
- set reason [lrange [split $arg] 2 end]
- set type 0
- set handle [nick2hand $gagger]
- set chan1 "$chan"
- foreach c [channels] {
- set backchan [channel get $c backchan]
- if {[string match -nocase $chan $backchan] && [channel get $c chanreport]} {
- set chan "$c"
- }
- }
- if {[regexp {^[&#]} $gagger] && [matchattr $hand nm|- $chan]} {
- set chan "$gagger"
- set gagger [lindex [split $arg] 1]
- set time [lindex [split $arg] 2]
- set reason [lrange [split $arg] 3 end]
- }
- if {![regexp {^[0-9]} $time]} {
- set reason [lrange [split $arg] 2 end]
- set time [channel get $chan gag-time]
- if {$time == "0"} {
- set time $black(gag_time)
- }
- }
- set split_text [split $gagger ","]
- if {$split_text != ""} {
- foreach txt $split_text {
- gag:process $txt $time $reason $nick $hand $host $chan $chan1 $type
- }
- } else { gag:process $gagger $time $reason $nick $hand $host $chan $chan1 $type }
- }
- ################################# ungag ###############################
- proc ungagpublic {nick host hand chan arg} {
- global black
- set gagger [lindex [split $arg] 0]
- set type 0
- set chan1 "$chan"
- foreach c [channels] {
- set backchan [channel get $c backchan]
- if {[string match -nocase $chan $backchan] && [channel get $c chanreport]} {
- set chan "$c"
- }
- }
- if {[regexp {^[&#]} $gagger] && [matchattr $hand nm|- $chan]} {
- set chan "$gagger"
- set gagger [lindex [split $arg] 1]
- }
- set split_text [split $gagger ","]
- if {$split_text != ""} {
- foreach txt $split_text {
- ungag:process $txt $nick $hand $host $chan $chan1 $type
- }
- } else { ungag:process $gagger $nick $hand $host $chan $chan1 $type }
- }
- proc ungag:process {gagger nick hand host chan chan1 type} {
- global black
- if {![validchan $chan]} {
- return
- }
- if {[matchattr $hand nm|- $chan]} {
- if {($gagger == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 ungag.1 none
- return
- }
- if {($gagger == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 ungag.2 none
- return
- }
- }
- if {($gagger == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 ungag.3 none
- return
- }
- if {($gagger == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 ungag.4 none
- return
- }
- if {[onchan $gagger $chan]} {
- set mask *!*@[lindex [split [getchanhost $gagger $chan] "@"] 1]
- } else {
- set mask $gagger
- }
- set counter 0
- set file [open $black(gag_file) "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
- foreach line $data {
- set counter [expr $counter + 1]
- set chanentry [lindex [split $line] 0]
- set hostentry [lindex $line 1]
- if {[string match -nocase $hostentry $mask] && [string match -nocase $chanentry $chan]} {
- set found_gag 1
- if {$line != ""} {
- set counter [expr $counter - 1]
- set delete [lreplace $data $counter $counter]
- set files [open $black(gag_file) "w"]
- puts $files [join $delete "\n"]
- close $files
- }
- }
- }
- set file [open $black(gag_file) "r"]
- set data [read -nonewline $file]
- close $file
- if {$data == ""} {
- set files [open $black(gag_file) "w"]
- close $files
- }
- if {![info exists found_gag]} {
- blacktools:tell $nick $host $hand $chan $chan1 ungag.5 $mask
- return
- } else {
- blacktools:tell $nick $host $hand $chan $chan1 ungag.6 $mask
- putquick "MODE $chan -b $mask"
- foreach user [chanlist $chan] {
- set the_mask *!*@[lindex [split [getchanhost $user $chan] "@"] 1]
- if {[string match -nocase $the_mask $mask]} {
- set found_one 1
- lappend object_found "$user"
- }
- }
- if {[info exists found_one]} {
-
- set getlang [string tolower [channel get $chan lang]]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
- set replace(%chan%) $chan
- set replace(%gagger%) $object_found
- set ungag_user_message [string map [array get replace] $black(say.$getlang.ungag.7)]
- set ungag_chan_message [string map [array get replace] $black(say.$getlang.ungag.8)]
- puthelp "PRIVMSG $gagger :$ungag_user_message"
- puthelp "PRIVMSG $chan :$ungag_chan_message"
- }
- }
- }
- proc gag:reban {nick host hand chan args} {
- global black
- set bans [lindex $args 1]
- if {![botisop $chan]} { return }
- set file [open $black(gag_file) "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
- foreach line $data {
- set chanentry [lindex [split $line] 0]
- set hostentry [lindex [split $line] 1]
- if {[string match -nocase $bans $hostentry] && [string match -nocase $chanentry $chan]} {
- putserv "MODE $chan +b $bans"
- }
- }
- }
-
- proc gag:autounban {minute hour day month year} {
- global black
- set counter "0"
- set file [open $black(gag_file) "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
- foreach line $data {
- set time_show [lindex [split $line] 2]
- if {[duration [expr $time_show - [unixtime]]] == "0 seconds"} {
- lappend gag_list $time_show
- }
- }
- if {[info exists gag_list]} {
- gag:autounban:check $gag_list
- }
- }
- proc gag:autounban:check {list} {
- global black
- set list [join $list]
- foreach tm $list {
- if {$tm != ""} {
- set file [open $black(gag_file) "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
- set i [lsearch -glob $data "* $tm *"]
- if {$i > -1} {
- set line [lindex $data $i]
- set mask [lindex [split $line] 1]
- set chan [lindex [split $line] 0]
- set delete [lreplace $data $i $i]
- set file [open $black(gag_file) "w"]
- puts $file [join $delete "\n"]
- close $file
- }
- }
- pushmode $chan -b $mask
- foreach user [chanlist $chan] {
- set the_mask *!*@[lindex [split [getchanhost $user $chan] "@"] 1]
- if {[string match -nocase $the_mask $mask]} {
- set found_one 1
- lappend object_found "$user"
- }
- }
- }
- if {[info exists found_one]} {
- set getlang [string tolower [channel get $chan lang]]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
-
- set replace(%chan%) $chan
- set replace(%gagger%) [join $object_found ", "]
- set ungag_chan_message [string map [array get replace] $black(say.$getlang.ungag.8)]
- puthelp "PRIVMSG $chan :$ungag_chan_message"
- }
- set file [open $black(gag_file) "r"]
- set data [read -nonewline $file]
- close $file
- if {$data == ""} {
- set files [open $black(gag_file) "w"]
- close $files
- }
- }
- ############################# Topic refresh #########################
- proc refreshpublic {nick host hand chan arg} {
- global botnick black
- set thetopic [topic $chan]
- puthelp "TOPIC $chan :$black(topics)"
- puthelp "TOPIC $chan :$thetopic"
- }
- proc times_topic {} {
- global black
- foreach chan [channels] {
- if {[channel get $chan topicrefresh] } {
- set thetopic [topic $chan]
- puthelp "TOPIC $chan :$black(topics)"
- puthelp "TOPIC $chan :$thetopic"
- }
- }
- timer $black(topic_time) times_topic
- return 1
- }
- ################################ count ####################################
- proc countpublic {nick host hand chan arg} {
- global black
- set type 0
- set chan1 "$chan"
- set why [lindex [split $arg] 0]
- if {[regexp {^[&#]} $why] && [matchattr $hand nm|M $why]} {
- set chan "$why"
- set why [lindex [split $arg] 1]
- }
- count:process $nick $host $hand $chan $chan1 $why $type
- }
- proc count:process {nick host hand chan chan1 why type} {
- global botnick black
- set char(p) [lindex $black(cmdchar) 0]
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- if {($why == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 count.1 none
- return
- }
- if {($why == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 count.2 none
- return
- }
- if {![validchan $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
- return
- }
- if {![onchan $botnick $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
- return
- }
- switch $why {
- on {
- if {[channel get $chan count]} {
- blacktools:tell $nick $host $hand $chan $chan1 count.3 none
- return
- }
- channel set $chan +count
- channel set $chan count-date [clock format [unixtime] -format "%m/%d/%Y"]
- blacktools:tell $nick $host $hand $chan $chan1 count.5 none
- }
- off {
- if {![channel get $chan count]} {
- blacktools:tell $nick $host $hand $chan $chan1 count.4 none
- return
- }
- channel set $chan -count
- channel set $chan count-date ""
- blacktools:tell $nick $host $hand $chan $chan1 count.6 none
- }
- display {
- set stats [channel get $chan countnumber]
- blacktools:tell $nick $host $hand $chan $chan1 count.7 $stats
- }
- reset {
- channel set $chan countnumber 0
- channel set $chan count-date ""
- blacktools:tell $nick $host $hand $chan $chan1 count.8 none
- }
- }
- }
- proc countpublic:join {nick host hand chan} {
- global black
- if {![validchan $chan]} { return }
- if {[isbotnick $nick]} { return }
- if {[channel get $chan count]} {
- if {[info exists black(turnOnFlood:$chan)]} {
- return
- }
- if {[channel get $chan count-date] == ""} {
- channel set $chan count-date [clock format [unixtime] -format "%m/%d/%Y"]
- }
- set stats [channel get $chan countnumber]
- set stats [expr $stats +1]
- channel set $chan countnumber $stats
- set replace(%num%) $stats
- set replace(%chan%) $chan
- set replace(%time%) [channel get $chan count-date]
- set countmessage [channel get $chan count-message]
- if {$countmessage == ""} {
- set getlang [string tolower [channel get $chan lang]]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
- set countmessage $black(say.$getlang.count.9)
- }
- putquick "NOTICE $nick :[string map [array get replace] $countmessage]"
- }
- }
- ############################### Private ##########################
- proc privatepublic {nick host hand chan arg} {
- global black
- set type 0
- set chan1 "$chan"
- set why [lindex [split $arg] 0]
- set user [lindex [split $arg] 1]
- set host [lindex [split $arg] 2]
- if {[regexp {^[&#]} $why] && [matchattr $hand nm|- $chan]} {
- set chan "$why"
- set why [lindex [split $arg] 1]
- set user [lindex [split $arg] 2]
- set host [lindex [split $arg] 3]
- }
- private:process $nick $host $hand $chan $chan1 $why $user $host $type
- }
- proc private:process {nick host hand chan chan1 why user host type} {
- global botnick black
- set char(p) [lindex $black(cmdchar) 0]
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- set flags "-|f"
- if {[matchattr $hand nm|- $chan]} {
- if {($why == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 private.1 none
- return
- }
- if {($why == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 private.2 none
- return
- }
- }
- if {($why == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 private.3 none
- return
- }
- if {($why == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 private.4 none
- return
- }
- if {![validchan $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
- return
- }
- if {![onchan $botnick $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
- return
- }
- if {([regexp -nocase -- {(#[0-9]+|on|off|add|list|del)} $why tmp privat]) && (![regexp -nocase -- {\S#} $why])} {
- switch $privat {
- on {
- channel set $chan +private
- blacktools:tell $nick $host $hand $chan $chan1 private.5 none
- }
- off {
- channel set $chan -private
- blacktools:tell $nick $host $hand $chan $chan1 private.6 none
- }
- add {
- if {[validuser $user]} {
- chattr $user $flags $chan
- blacktools:tell $nick $host $hand $chan $chan1 private.7 $user
- return
- }
- adduser $user $host
- chattr $user $flags $chan
- blacktools:tell $nick $host $hand $chan $chan1 private.8 "$user $host"
- }
- del {
- if {[validuser $user]} {
- chattr $user -|-f $chan
- blacktools:tell $nick $host $hand $chan $chan1 private.9 $user
- } else { blacktools:tell $nick $host $hand $chan $chan1 private.10 $user
- return
- }
- }
- list {
- set list [userlist $flags $chan]
- blacktools:tell $nick $host $hand $chan $chan1 private.11 $list
- }
- }
- }
- }
- proc private:module {nick host hand chan} {
- global black botnick
- set getreason [channel get $chan private-reason]
- if {$getreason == ""} {
- set getlang [string tolower [channel get $chan lang]]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
- set getreason $black(say.$getlang.private.12)
- }
- set getbantime [channel get $chan private-bantime]
- if {$getbantime == "0"} { set getbantime $black(privatebantime) }
- set handle [nick2hand $nick]
- set mask "*!*@[lindex [split $host @] 1]"
- if {[channel get $chan private]} {
- if {[matchattr $handle nm|oMASOVf $chan]} {
- return
- }
- newchanban $chan $mask $botnick $getreason $getbantime
- }
- }
- ############################### BadChan ###########################
- proc badchanpublic {nick host hand chan arg} {
- global black
- set why [lindex [split $arg] 0]
- set type1 0
- set chan1 "$chan"
- set bdchan [join [lindex [split $arg] 1]]
- set type [lindex [split $arg] 2]
- set reason [join [lrange [split $arg] 2 end]]
- if {[string equal -nocase $why "list"] || [string equal -nocase $why "status"]} {
- set type [lindex [split $arg] 1]
- }
- if {[string equal -nocase $type "-global"]} {
- set reason [join [lrange [split $arg] 3 end]]
- }
- if {[regexp {^[&#]} $why] && [matchattr $hand nm|M $why]} {
- set chan "$why"
- set why [lindex [split $arg] 1]
- set bdchan [join [lindex [split $arg] 2]]
- set type [lindex [split $arg] 3]
- set reason [join [lrange [split $arg] 3 end]]
- if {[string equal -nocase $why "list"] || [string equal -nocase $why "status"]} {
- set type [lindex [split $arg] 3]
- }
- if {[string equal -nocase $type "-global"]} {
- set reason [join [lrange [split $arg] 4 end]]
- }
- }
- badchan:process $nick $host $hand $chan $chan1 $why $bdchan $type $type1 $reason
- }
- proc badchan:process {nick host hand chan chan1 why bdchan type type1 reason} {
- global botnick black username
- set dir "scripts/BlackTools/FILES/$username.badchannels.txt"
- set local ""
- set char(p) [lindex $black(cmdchar) 0]
-
- if {[matchattr $hand nm|- $chan]} {
- if {($why == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.3 none
- return
- }
- if {($why == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.4 none
- return
- }
- }
- if {($why == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.1 none
- return
- }
- if {($why == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.2 none
- return
- }
- if {![validchan $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
- return
- }
- if {![onchan $botnick $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
- return
- }
-
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- switch $why {
- on {
- if {[channel get $chan antibadchan]} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.5 none
- return
- }
- channel set $chan +antibadchan
- blacktools:tell $nick $host $hand $chan $chan1 badchan.6 none
- }
- off {
- if {![channel get $chan antibadchan]} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.7 none
- return
- }
- channel set $chan -antibadchan
- blacktools:tell $nick $host $hand $chan $chan1 badchan.8 none
- }
- add {
- if {$bdchan == ""} {
- if {[matchattr $hand mn]} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.9 none
- return
- } else {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.10 none
- return
- }
- }
- if {$reason == ""} {
- set reason "NONE"
- }
- if {[matchattr $hand mn] && [string equal -nocase $type "-global"]} {
- set file [open $dir a]
- puts $file "GLOBAL $bdchan $reason"
- close $file
- set local "Global-List"
- } else {
- set file [open $dir a]
- puts $file "$chan $bdchan $reason"
- close $file
- set local "Local-List"
- }
- if {$reason == "NONE"} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.11 "$local $bdchan $reason"
- } else {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.12 "$local $bdchan $reason"
- }
- }
- list {
- set file [open $dir "r"]
- set check_global 0
- set found_it 0
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set counter 0
- if {$data == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.13 none
- return
- }
- if {[matchattr $hand mn] && [string equal -nocase $type "-global"]} {
- set check_global 1
- }
- blacktools:tell $nick $host $hand $chan $chan1 badchan.14 none
- foreach line $data {
- set mainchan [lindex [split $line] 0]
- set badchan [lindex [split $line] 1]
- set reason [join [lrange [split $line] 2 end]]
- if {$check_global == 1} {
- if {[string equal -nocase $mainchan "GLOBAL"]} {
- set counter [expr $counter +1]
- set found_it 1
- if {$reason == "NONE"} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.15 "$counter $badchan"
- } else {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.16 "$counter $badchan $reason"
- }
- }
- } else {
- if {[string equal -nocase $mainchan $chan]} {
- set found_it 1
- set counter [expr $counter +1]
- if {$reason == "NONE"} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.17 "$counter $badchan"
- } else {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.18 "$counter $badchan $reason"
- }
- }
- }
- }
- if {$found_it == 0} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.19 none
- }
- }
- del {
- set check_global 0
- set found_it 0
- set line_count 0
-
- if {$bdchan == ""} {
- if {[matchattr $hand mn]} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.20 none
- return
- } else {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.21 none
- return
- }
- }
- if {[matchattr $hand mn] && [string equal -nocase $type "-global"]} {
- set check_global 1
- }
- set file [open $dir "r"]
- set data [read -nonewline $file]
- close $file
- set lines [split $data "\n"]
- foreach line $lines {
- set line_count [expr $line_count + 1]
- set mainchan [lindex [split $line] 0]
- set badchan [lindex [split $line] 1]
- if {$check_global == 1} {
- if {[string equal -nocase $mainchan "GLOBAL"] && [string equal -nocase $badchan $bdchan]} {
- set found_it 1
- blacktools:tell $nick $host $hand $chan $chan1 badchan.22 "$badchan"
- if {$line != ""} {
- set line_count [expr $line_count - 1]
- set delete [lreplace $lines $line_count $line_count]
- set files [open $dir "w"]
- puts $files [join $delete "\n"]
- close $files
- }
- }
-
- } else {
- if {[string equal -nocase $mainchan $chan] && [string equal -nocase $badchan $bdchan]} {
- set found_it 1
- if {$line != ""} {
- set line_count [expr $line_count - 1]
- set delete [lreplace $lines $line_count $line_count]
- set files [open $dir "w"]
- puts $files [join $delete "\n"]
- close $files
- }
- blacktools:tell $nick $host $hand $chan $chan1 badchan.23 "$badchan"
- }
- }
- }
- if {$found_it == 0} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.24 none
- }
- }
- find {
- set found_it 0
- set counter 0
- set check_global 0
-
- if {$bdchan == ""} {
- if {[matchattr $hand mn]} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.25 none
- return
- } else {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.26 none
- return
- }
- }
-
- if {[matchattr $hand mn] && [string equal -nocase $type "-global"]} {
- set check_global 1
- }
- set file [open $dir "r"]
- set data [read -nonewline $file]
- close $file
- set lines [split $data "\n"]
- foreach line $lines {
- set mainchan [lindex [split $line] 0]
- set badchan [lindex [split $line] 1]
- if {$check_global == 1} {
- if {[string equal -nocase $mainchan "GLOBAL"] && [string match -nocase $bdchan $badchan]} {
- set counter [expr $counter + 1]
- set found_it 1
- set reason [join [lrange [split $line] 2 end]]
- if {$reason == "NONE"} { set reason "\"Default reason\"" }
- blacktools:tell $nick $host $hand $chan $chan1 badchan.27 "$counter $badchan $reason"
- }
- } else {
- if {[string equal -nocase $mainchan $chan] && [string match -nocase $bdchan $badchan]} {
- set counter [expr $counter + 1]
- set found_it 1
- set reason [join [lrange [split $line] 2 end]]
- blacktools:tell $nick $host $hand $chan $chan1 badchan.28 "$counter $badchan $reason"
- }
- }
- }
- if {$found_it == 0} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.24 none
- }
- }
- status {
- set check_global 0
- if {[matchattr $hand mn] && [string equal -nocase $type "-global"]} {
- set check_global 1
- }
- if {[channel get $chan antibadchan]} { set status ONLINE } else { set status OFFLINE }
- blacktools:tell $nick $host $hand $chan $chan1 badchan.29 $status
- if {$check_global == 1} {
- set total_chans [get:badchan:stats "GLOBAL"]
- blacktools:tell $nick $host $hand $chan $chan1 badchan.30 $total_chans
- } else {
- set total_chans [get:badchan:stats $chan]
- blacktools:tell $nick $host $hand $chan $chan1 badchan.31 $total_chans
- }
- if {[channel get $chan badchan-reason] == ""} {
- set getlang [string tolower [channel get $chan lang]]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
- set reason $black(say.$getlang.badchan.39)
- } else { set reason [join [channel get $chan badchan-reason]]}
- if {[channel get $chan badchan-bantime] == 0} { set bantime $black(badcbantime)} else { set bantime [channel get $chan badchan-bantime]}
- blacktools:tell $nick $host $hand $chan $chan1 badchan.32 $reason
- blacktools:tell $nick $host $hand $chan $chan1 badchan.33 $bantime
- }
- set {
-
- switch $bdchan {
- reason {
- if {$reason == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.34 none
- return
- }
- channel set $chan badchan-reason "$reason"
- blacktools:tell $nick $host $hand $chan $chan1 badchan.35 $reason
- }
- bantime {
- if {$type == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.36 none
- return
- }
- channel set $chan badchan-bantime $type
- blacktools:tell $nick $host $hand $chan $chan1 badchan.37 $type
- }
- default {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.38 none
-
- }
- }
- }
- default {
- if {[matchattr $hand mn]} {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.3 none
- } else {
- blacktools:tell $nick $host $hand $chan $chan1 badchan.1 none
- }
- }
- }
- }
- proc get:badchan:stats {type} {
- global black username
- set dir "scripts/BlackTools/FILES/$username.badchannels.txt"
- set counter 0
- set file [open $dir "r"]
- set data [read -nonewline $file]
- close $file
- set lines [split $data "\n"]
- foreach line $lines {
- set mainchan [lindex [split $line] 0]
- if {[string equal -nocase $type $mainchan]} {
- set counter [expr $counter + 1]
- }
- }
- return $counter
- }
- proc badchanpublic:join {nick host hand chan} {
- global black
- set ::bad_chan $chan
- if {[matchattr $hand $black(exceptflags) $chan]} {
- return
- }
- if {![validchan $chan]} { return }
- if {![botisop $chan]} { return }
- if {[isbotnick $nick]} { return }
- if {[channel get $chan antibadchan]} {
- utimer 5 [list putquick "WHOIS $nick $nick"]
- bind RAW - 319 badchan:execute
- }
- }
- proc badchan:execute {from keyword arguments } {
- global botnick black badchan username
- set chan $::bad_chan
- set dir "scripts/BlackTools/FILES/$username.badchannels.txt"
- set arguments [join $arguments]
- set nick [string tolower [lindex $arguments 1]]
- set channels [string tolower [lrange $arguments 2 end]]
- set banmask *!*@[lindex [split [getchanhost $nick $chan] "@"] 1]
- if {![onchan $nick $chan]} {
- return
- }
- set file [open $dir "r"]
- set database [read -nonewline $file]
- set bantime ""
- close $file
- set data [split $database "\n"]
- foreach line $data {
- set mainchan [lindex [split $line] 0]
- if {[string equal -nocase $chan $mainchan] || [string equal -nocase "GLOBAL" $mainchan]} {
- set readchan [lindex [split $line] 1]
- set reason [join [lrange [split $line] 2 end]]
- foreach c [join $channels] {
- set ch [string trimleft $c ":@+"]
- if {[string equal -nocase $readchan $ch]} {
- if {[string equal -nocase "LOCAL" $mainchan]} {
- if {[channel get $chan badchan-reason] == 0} {
- set bantime $black(badcbantime)
- } else { set bantime [channel get $chan badchan-reason] }
- } else { set bantime $black(badcbantime) }
- if {[string equal -nocase $chan $mainchan] && [string equal -nocase $reason "NONE"]} {
- if {[channel get $chan badchan-reason] == ""} {
- set getlang [string tolower [channel get $chan lang]]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
- set reason $black(say.$getlang.badchan.39)
- } else { set reason [join [channel get $chan badchan-reason]]
- }
- }
- if {[string equal -nocase "GLOBAL" $mainchan] && [string equal -nocase $reason "NONE"]} {
- set getlang [string tolower [channel get $chan lang]]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
- set reason $black(say.$getlang.badchan.39)
- }
- set badchan($banmask:$chan) $reason
- lappend badchan(channels:$banmask:$chan) $readchan
- }
- }
- }
- }
- if {[info exists badchan(checkagain:$banmask:$chan)]} {
- if {[info exists badchan($banmask:$chan)]} {
- set bywho "[join $badchan(channels:$banmask:$chan) ","]"
- bad:add:word $chan $banmask $bywho
- set replace(%chan%) $chan
- set reason [string map [array get replace] $badchan($banmask:$chan)]
- blacktools:banner:2 $banmask "BADCHAN" $chan $reason $bantime
- unset badchan(checkagain:$banmask:$chan)
- unset badchan($banmask:$chan)
- unset badchan(channels:$banmask:$chan)
- return
- }
- unset badchan(checkagain:$banmask:$chan)
- return
- }
- if {[info exists badchan($banmask:$chan)]} {
- set replace(%badchans%) [join $badchan(channels:$banmask:$chan) ", "]
- set getlang [string tolower [channel get $chan lang]]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
- set get_message $black(say.$getlang.badchan.40)
- set message [string map [array get replace] $get_message]
- putquick "PRIVMSG $nick :\[$chan\] $message"
- utimer 30 [list badchan:check:again $nick $chan]
- unset badchan($banmask:$chan)
- unset badchan(channels:$banmask:$chan)
- set badchan(checkagain:$banmask:$chan) 1
- } else {
- if {[info exists badchan(checkagain:$banmask:$chan]} {
- unset badchan(checkagain:$banmask:$chan
- }
- if {[info exists badchan($banmask:$chan)]} {
- unset badchan($banmask:$chan)
- }
- if {[info exists badchan(channels:$banmask:$chan)]} {
- unset badchan(channels:$banmask:$chan)
- }
- }
- unbind RAW - 319 badchan:execute
- }
- proc badchan:check:again {nick chan} {
- putquick "WHOIS $nick $nick"
- set ::bad_chan $chan
- bind RAW - 319 badchan:execute
- }
- proc badchan:nickchange {nick host hand chan newnick} {
- global badchan
- set found_time 0
- set current_time ""
- foreach tmr [utimers] {
- if {[string match -nocase "*badchan:check:again $nick $chan*" [join [lindex $tmr 1]]]} {
- set current_time [get:timer:time $nick $chan]
- set found_time 1
- killutimer [lindex $tmr 2]
- }
- }
- if {$found_time == "1"} {
- utimer $current_time [list badchan:check:again $newnick $chan]
- }
- }
- proc badchan:split {nick host hand chan args} {
- global badchan
- badchan:part $nick $host $hand $chan "none"
- }
- proc badchan:kick {nick host hand chan kicked reason} {
- global badchan
- badchan:part $kicked $host $hand $chan "none"
- }
- proc badchan:part {nick host hand chan arg} {
- global badchan
- if {![validchan $chan]} { return }
- set banmask *!*@[lindex [split [getchanhost $nick $chan] "@"] 1]
- foreach tmr [utimers] {
- if {[string match -nocase "*badchan:check:again $nick $chan*" [join [lindex $tmr 1]]]} {
- killutimer [lindex $tmr 2]
- }
- }
- if {[info exists badchan(checkagain:$banmask:$chan)]} {
- unset badchan(checkagain:$banmask:$chan)
- }
- if {[info exists badchan($banmask:$chan)]} {
- unset badchan($banmask:$chan)
- }
- if {[info exists badchan(channels:$banmask:$chan)]} {
- unset badchan(channels:$banmask:$chan)
- }
- }
- proc get:timer:time {nick chan} {
- global scrabble
- set time_left 0
- foreach tmr [utimers] {
- if {[string match -nocase "*badchan:check:again $nick $chan*" [join [lindex $tmr 1]]]} {
- set time_left [lindex $tmr 0]
- }
- }
- return $time_left
- }
- ################################# Antitake ##################################
- proc dontdeoppublic {nick host hand chan args} {
- global black botnick
- set dnick [lindex $args 1]
- set handle [nick2hand $nick]
- if {[channel get $chan dontdeop] } {
- if {[string match -nocase $nick $botnick]} {
- return
- }
- if {![matchattr $handle $black(exceptflags) $chan]} {
- putquick "MODE $chan -o $nick"
- putquick "MODE $chan +o $dnick"
- set getlang [string tolower [channel get $chan lang]]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
- puthelp "NOTICE $nick :$black(say.$getlang.antitake.1)"
- }
- }
- }
-
- proc dontoppublic {nick host hand chan args} {
- global black botnick
- set onick [lindex $args 1]
- set handle [nick2hand $nick]
- if {[channel get $chan dontop]} {
- if {[string match -nocase $nick $botnick]} {
- return
- }
- if {[string match -nocase $onick $botnick]} {
- return
- }
- if {![matchattr $handle $black(exceptflags) $chan]} {
- putquick "MODE $chan -o $nick"
- putquick "MODE $chan -o $onick"
- set getlang [string tolower [channel get $chan lang]]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
- puthelp "NOTICE $nick :$black(say.$getlang.antitake.2)"
- }
- }
- }
- ################################# Anunt ###################################
- proc anuntpublic {nick host hand chan arg} {
- global black
- set type 0
- set chan1 "$chan"
- set who [lindex [split $arg] 0]
- set message [join [lrange [split $arg] 1 end]]
- set number [lindex [split $arg] 1]
- if {[regexp {^[&#]} $who] && [matchattr $hand nm|M $who]} {
- set chan "$who"
- set who [lindex [split $arg] 1]
- set message [join [lrange [split $arg] 2 end]]
- set number [lindex [split $arg] 2]
- }
- anunt:process $nick $host $hand $chan $chan1 $who $message $number $type
- }
- proc anunt:process {nick host hand chan chan1 who message number type} {
- global botnick black username
- set char(p) [lindex $black(cmdchar) 0]
- set new_dir "scripts/BlackTools/FILES/$username.announce.txt"
-
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- if {($who == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 anunt.1 none
- return
- }
- if {($who == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 anunt.2 none
- return
- }
- if {![validchan $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
- return
- }
- if {![onchan $botnick $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
- return
- }
- switch $who {
- on {
- channel set $chan +anunt
- blacktools:tell $nick $host $hand $chan $chan1 anunt.3 none
- }
- off {
- channel set $chan -anunt
- blacktools:tell $nick $host $hand $chan $chan1 anunt.4 none
- }
- add {
- if {$message == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 anunt.12 none
- return
- }
- set file [open $new_dir a]
- puts $file "$chan $message"
- close $file
- blacktools:tell $nick $host $hand $chan $chan1 anunt.5 none
- blacktools:tell $nick $host $hand $chan $chan1 anunt.6 $message
- }
- list {
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set i 0
- if {$data == ""} { blacktools:tell $nick $host $hand $chan $chan1 anunt.7 none
- return
- }
- blacktools:tell $nick $host $hand $chan $chan1 anunt.8 none
- foreach line $data {
- set read_chan [lindex [split $line] 0]
- if {[string match -nocase $read_chan $chan]} {
- set i [expr $i +1]
- set message [join [lrange [split $line] 1 end]]
- blacktools:tell $nick $host $hand $chan $chan1 anunt.6 "$i. $message"
- }
- }
- }
- del {
- array set anuntdel [list]
- if {![regexp {^[0-9]} $number]} {
- blacktools:tell $nick $host $hand $chan $chan1 anunt.9 none
- return
- }
- set file [open $new_dir "r"]
- set data [read -nonewline $file]
- close $file
- set lines [split $data "\n"]
- set counter -1
- set line_counter -1
- set current_place -1
- foreach line $lines {
- set line_counter [expr $line_counter + 1]
- set read_chan [lindex [split $line] 0]
- if {[string match -nocase $read_chan $chan]} {
- set counter [expr $counter + 1]
- set anuntdel($counter) $line_counter
- }
- }
- foreach place [array names anuntdel] {
- if {$place == [expr $number - 1]} {
- set current_place $anuntdel($place)
- }
- }
- if {$current_place == "-1"} {
- blacktools:tell $nick $host $hand $chan $chan1 anunt.13 $number
- return
- }
- set delete [lreplace $lines $current_place $current_place]
- set files [open $new_dir "w"]
- puts $files [join $delete "\n"]
- close $files
- set file [open $new_dir "r"]
- set data [read -nonewline $file]
- close $file
- if {$data == ""} {
- set files [open $new_dir "w"]
- close $files
- }
- blacktools:tell $nick $host $hand $chan $chan1 anunt.10 $number
- blacktools:tell $nick $host $hand $chan $chan1 anunt.11 none
- }
- }
- }
- proc anuntpublic:show {} {
- global black
- foreach chan [channels] {
- if {[validchan $chan]} {
- if {[channel get $chan anunt]} {
- lappend black(anunt:chans) [join $chan]
- }
- }
- }
- if {[info exists black(anunt:chans)]} {
- anunt:time
- } else {
- timer $black(anunttime) anuntpublic:show
- return 1
- }
- }
- proc anunt:time {} {
- global black
-
- if {![info exists black(anunt:count:chans)]} {
- set black(anunt:count:chans) 0
- }
- set current_chan [lindex $black(anunt:chans) $black(anunt:count:chans)]
- set black(anunt:count:chans) [expr $black(anunt:count:chans) + 1]
- if {$current_chan != ""} {
- anunt:show $current_chan
- anunt:time
- } else {
- unset black(anunt:count:chans)
- unset black(anunt:chans)
- timer $black(anunttime) anuntpublic:show
- return 1
- }
- }
- proc anunt:show {chan} {
- global black count username
- set new_dir "scripts/BlackTools/FILES/$username.announce.txt"
- set temp_dir "scripts/BlackTools/FILES/announce.temp.txt"
- if {![file exists $temp_dir]} {
- set file [open $temp_dir w]
- close $file
- } else {
- set file [open $temp_dir w]
- close $file
- }
- set file [open $new_dir "r"]
- set data [read -nonewline $file]
- close $file
- if {$data != ""} {
- set lines [split $data "\n"]
- foreach line $lines {
- set read_chan [lindex [split $line] 0]
- if {[string match -nocase $read_chan $chan]} {
- set file [open $temp_dir "a"]
- puts $file [join [lrange [split $line] 1 end]]
- close $file
- }
- }
- }
- set file [open $temp_dir "r"]
- set data [read -nonewline $file]
- close $file
- if {$data != ""} {
- if {![info exists count(anunt:$chan)]} {
- set count(anunt:$chan) 0
- }
- set lines [split $data "\n"]
- set line [lindex $lines $count(anunt:$chan)]
-
- if {$line == ""} {
- set count(anunt:$chan) 0
- set line [lindex $lines $count(anunt:$chan)]
- }
- set split_line [split $line "~"]
- incr count(anunt:$chan)
- foreach mes $split_line {
- if {$black(anunthow) == "1"} {
- puthelp "PRIVMSG $chan :\001ACTION $mes\001"
- } else {
- puthelp "PRIVMSG $chan :$mes"
- }
- }
- }
- set file [open $temp_dir "w"]
- close $file
- }
- ################################## TimeBan #############################
- proc timeban:module {nick host hand chan} {
- global botnick
- if {[channel get $chan showtime]} {
- set host "$nick![getchanhost $nick $chan]"
- foreach ban [banlist $chan] {
- if {[string match -nocase [string tolower [lindex $ban 0]] $host]} {
- set reason "[lindex $ban 1]"
- set bantime "[lindex $ban 2]"
- set totalday [expr $bantime - [unixtime]]
- if {$totalday >= 86400} {
- set daysfull [expr $totalday/86400]
- set days [expr int($daysfull)]
- set dayssub [expr 86400*$days]
- set totalhour [expr $totalday - $dayssub]
- }
- if {$totalday < 86400} {
- set totalhour $totalday
- set days 0
- }
- if {$totalhour >= 3600} {
- set hoursfull [expr $totalhour/3600]
- set hours [expr int($hoursfull)]
- set hourssub [expr 3600*$hours]
- set totalmin [expr $totalhour - $hourssub]
- }
- if {$totalhour < 3600} {
- set totalmin $totalhour
- set hours 0
- }
- if {$totalmin >= 60} {
- set minsfull [expr $totalmin/60]
- set mins [expr int($minsfull)]
- }
- if {$totalmin < 60} {
- set mins 0
- }
- if {$days < 1} {set zi "0 days, "} elseif {$days == 1} {set zi "$days day, "} {set zi "$days days, "}
- if {$hours < 1} {set ora "0"} else { set ora "$hours" }
- set minut "$mins"
- set re "$reason \[$zi$ora:$minut\]"
- if {[lindex $ban 2] == 0} {
- set expire "\[Never\]"
- set re "$reason $expire"
- }
- putquick "MODE $chan +b [lindex $ban 0]"
- putquick "KICK $chan $nick :$re"
- }
- }
- }
- }
- ############################### AutoBroadcast ############################
- proc broadcastpublic:module {nick host hand chan arg} {
- global black sdir
- set char(p) [lindex $black(cmdchar) 0]
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- set chan1 "$chan"
- set who [lindex [split $arg] 0]
- set message [join [lrange [split $arg] 1 end]]
- set number [lindex [split $arg] 1]
- if {$who == ""} { blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.1 none
- return
- }
- broadcast:process $nick $host $hand $chan $chan1 $who $message $number
- }
- proc broadcast:process {nick host hand chan chan1 who message number} {
- global botnick black username
- set message [join $message]
- set sdir "scripts/BlackTools/FILES/$username.status.txt"
- set char(p) [lindex $black(cmdchar) 0]
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- set dir "scripts/BlackTools/FILES/$username.autobroadcast.txt"
- set lin 0
- switch $who {
- on {
- set type "broadcastpublic:show ON"
- foreach tmr [timers] {
- if {[string match "*broadcastpublic:show*" [join [lindex $tmr 1]]]} {
- blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.3 none
- return
- }
- }
- blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.4 none
- set file [open $sdir "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
- foreach line $data {
- set lin [expr $lin +1]
- set who [lindex [split $line] 0]
- set stats [lindex [split $line] 1]
- if {[string match -nocase "broadcastpublic:show" $who]} {
- if {$line != ""} {
- set num [expr $lin - 1]
- set delete [lreplace $data $num $num]
- set files [open $sdir "w"]
- puts $files [join $delete "\n"]
- close $files
- }
- }
- }
- set file [open $sdir "r"]
- set data [read -nonewline $file]
- close $file
- if {$data == ""} {
- set files [open $sdir "w"]
- close $files
- }
- set file [open $sdir "a"]
- puts $file "$type"
- close $file
- timer $black(bttime) broadcastpublic:show
- set broadcastpublic:show_running 1
- }
- off {
- blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.5 none
- set type "broadcastpublic:show OFF"
- foreach tmr [timers] {
- if {[string match -nocase "*broadcastpublic:show*" [join [lindex $tmr 1]]]} {
- killtimer [lindex $tmr 2]
- }
- }
- set file [open $sdir "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
- foreach line $data {
- set lin [expr $lin +1]
- set who [lindex [split $line] 0]
- set stats [lindex [split $line] 1]
- if {[string match -nocase "broadcastpublic:show" $who]} {
- if {$line != ""} {
- set num [expr $lin - 1]
- set delete [lreplace $data $num $num]
- set files [open $sdir "w"]
- puts $files [join $delete "\n"]
- close $files
- }
- }
- }
- set file [open $sdir "r"]
- set data [read -nonewline $file]
- close $file
- if {$data == ""} {
- set files [open $sdir "w"]
- close $files
- }
- set file [open $sdir "a"]
- puts $file "$type"
- close $file
- if {[info exists broadcastpublic:show_running]} {
- unset broadcastpublic:show_running
- }
- }
- add {
- if {$message == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.12 none
- return
- }
- set file [open $dir a]
- puts $file $message
- close $file
- blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.6 none
- blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.7 $message
- }
- list {
- set file [open $dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set i 0
- if {$data == ""} { blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.8 none
- return
- }
- blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.9 none
- foreach mes $data {
- set i [expr $i +1]
- blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.7 "$i. $mes"
- }
- }
- del {
- if {![regexp {^[0-9]} $number]} {
- blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.10 none
- return
- }
- set file [open $dir "r"]
- set data [read -nonewline $file]
- close $file
- set lines [split $data "\n"]
- set i [expr $number - 1]
- set delete [lreplace $lines $i $i]
- set files [open $dir "w"]
- puts $files [join $delete "\n"]
- close $files
- set file [open $dir "r"]
- set data [read -nonewline $file]
- close $file
- if {$data == ""} {
- set files [open $dir "w"]
- close $files
- }
- blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.11 $number
- }
- }
- }
- proc broadcastpublic:show {} {
- global black username
- set dir "scripts/BlackTools/FILES/$username.autobroadcast.txt"
-
- if {![info exists black(broadcast:count)]} {
- set black(broadcast:count) 0
- }
- set file [open $dir "r"]
- set data [read -nonewline $file]
- close $file
- if {$data != ""} {
- set lines [split $data "\n"]
- set line [lindex $lines $black(broadcast:count)]
-
- if {$line == ""} {
- set black(broadcast:count) 0
- set line [lindex $lines $black(broadcast:count)]
- }
- set black(broadcast:count) [expr $black(broadcast:count) +1]
- set split_line [split $line "~"]
- foreach chan [channels] {
- if {[validchan $chan] && [isdynamic $chan] && (![channel get $chan silent])} {
- foreach mes $split_line {
- if {$black(bthow) == "1"} {
- puthelp "PRIVMSG $chan :\001ACTION $mes\001"
- } else {
- puthelp "PRIVMSG $chan :$mes"
- }
- }
- }
- }
- }
- timer $black(bttime) broadcastpublic:show
- return
- }
- ################################# Limit ###################################
- proc limitpublic {nick host hand chan arg} {
- global black
- set why [lindex [split $arg] 0]
- set lm [lindex [split $arg] 1]
- set type 0
- set chan1 "$chan"
- if {[regexp {^[&#]} $why] && [matchattr $hand nm|- $chan]} {
- set chan "$why"
- set why [lindex [split $arg] 1]
- set lm [lindex [split $arg] 2]
- }
- limit:process $nick $host $hand $chan $chan1 $why $lm $type
- }
- proc limit:process {nick host hand chan chan1 why lm type} {
- global botnick black
- set char(p) [lindex $black(cmdchar) 0]
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- if {[matchattr $hand nm|- $chan]} {
- if {($why == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 limit.1 none
- return
- }
- if {($why == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 limit.2 none
- return
- }
- }
- if {($why == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 limit.3 none
- return
- }
- if {($why == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 limit.4 none
- return
- }
- if {![validchan $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
- return
- }
- if {![onchan $botnick $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
- return
- }
- set usersnum [llength [chanlist $chan]]
- set setnum [channel get $chan blacklimit]
-
- if {([regexp -nocase -- {(#[0-9]+|on|off|set|on|off)} $why tmp lmt]) && (![regexp -nocase -- {\S#} $why])} {
- switch $lmt {
- on {
- set limt [channel get $chan blacklimit]
- channel set $chan +limit
- blacktools:tell $nick $host $hand $chan $chan1 limit.5 none
- if {($limt != "0")} {
- putserv "MODE $chan +l [expr $usersnum + $limt]"
- } else {
- putserv "MODE $chan +l [expr $usersnum + 10]"
- channel set $chan blacklimit 10
- blacktools:tell $nick $host $hand $chan $chan1 limit.6 none
- }
- }
- off {
- channel set $chan -limit
- blacktools:tell $nick $host $hand $chan $chan1 limit.7 none
- putquick "MODE $chan -l"
- }
- set {
- if {![regexp {^[0-9]} $lm]} {
- blacktools:tell $nick $host $hand $chan $chan1 limit.8 none
- return
- }
- if {$lm < 2} { blacktools:tell $nick $host $hand $chan $chan1 limit.9 none
- channel set $chan blacklimit 2
- putserv "MODE $chan +l [expr $usersnum + $lm]"
- blacktools:tell $nick $host $hand $chan $chan1 limit.10 none
- return
- }
- if {$lm > 500} { blacktools:tell $nick $host $hand $chan $chan1 limit.11 none
- return
- }
- channel set $chan blacklimit $lm
- blacktools:tell $nick $host $hand $chan $chan1 limit.12 $lm
- putserv "MODE $chan +l [expr $usersnum + $lm]"
- }
- }
- }
- }
- proc limit:timer {min hour day mon year} {
- global black
- foreach chan [channels] {
- if {[channel get $chan limit]} {
- set usersnum [llength [chanlist $chan]]
- set setnum [channel get $chan blacklimit]
- if {$setnum == "0"} { set setnum "10" }
- if {![botisop $chan]} { return 0 }
- set chanmode [getchanmode $chan]
- if {[string match "*l*" "$chanmode"]} {
- set lim [lindex $chanmode 1]
- } else { set lim "0" }
- if {$usersnum > $lim} { set dif [expr $usersnum - $lim] } else { set dif [expr $lim - $usersnum] }
- if {($dif >= $setnum) || ($dif <= $setnum)} {
- putserv "MODE $chan +l [expr $usersnum + $setnum]"
- }
- }
- }
- }
- ################################# Topic ###################################
- proc topicpublic {nick host hand chan arg} {
- global black
- set nop [lindex [split $arg] 0]
- set char(p) [lindex $black(cmdchar) 0]
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- set type 0
- set chan1 "$chan"
- set tp [join [lrange [split $arg] 1 end]]
- set number [lindex [split $arg] 1]
- if {[regexp {^[&#]} $nop] && [matchattr $hand nm|M $nop]} {
- set chan "$nop"
- set nop [lindex [split $arg] 1]
- set tp [join [lrange [split $arg] 2 end]]
- set number [lindex [split $arg] 2]
- }
- topic:process $nick $host $hand $chan $chan1 $nop $tp $number $type
- }
- proc topic:process {nick host hand chan chan1 nop tp number type} {
- global botnick black username
- set char(p) [lindex $black(cmdchar) 0]
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- set new_dir "scripts/BlackTools/FILES/$username.topic.txt"
-
- if {($nop == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 topic.1 none
- return
- }
- if {($nop == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 topic.2 none
- return
- }
- if {![validchan $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
- return
- }
- if {![onchan $botnick $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
- return
- }
- switch $nop {
-
- save {
- set t [join [topic $chan]]
- if {$t == ""} { blacktools:tell $nick $host $hand $chan $chan1 topic.3 none
- return
- }
- set file [open $new_dir a]
- puts $file $t
- close $file
- blacktools:tell $nick $host $hand $chan $chan1 topic.4 none
- }
- add {
- if {$tp == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 topic.13 none
- return
- }
- set file [open $new_dir a]
- puts $file "$chan $tp"
- close $file
- blacktools:tell $nick $host $hand $chan $chan1 topic.5 none
- }
- list {
-
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set i 0
- set found_it 0
- if {$data == ""} { blacktools:tell $nick $host $hand $chan $chan1 topic.6 none
- return
- }
- blacktools:tell $nick $host $hand $chan $chan1 topic.7 none
- foreach line $data {
- set read_chan [lindex [split $line] 0]
- if {[string match -nocase $read_chan $chan]} {
- set found_it 1
- set topic [join [lrange [split $line] 1 end]]
- set i [expr $i +1]
- blacktools:tell $nick $host $hand $chan $chan1 topic.8 "$i. $topic"
- }
- }
- if {$found_it == 0} {
- blacktools:tell $nick $host $hand $chan $chan1 topic.6 none
- return
- }
- }
- del {
- array set topicdel [list]
- if {![regexp {^[0-9]} $number]} {
- blacktools:tell $nick $host $hand $chan $chan1 topic.9 none
- return
- }
- set file [open $new_dir "r"]
- set data [read -nonewline $file]
- close $file
- set lines [split $data "\n"]
- set counter -1
- set line_counter -1
- set current_place -1
- foreach line $lines {
- set line_counter [expr $line_counter + 1]
- set read_chan [lindex [split $line] 0]
- if {[string match -nocase $read_chan $chan]} {
- set counter [expr $counter + 1]
- set topicdel($counter) $line_counter
- }
- }
- foreach place [array names topicdel] {
- if {$place == [expr $number - 1]} {
- set current_place $topicdel($place)
- }
- }
- if {$current_place == "-1"} {
- blacktools:tell $nick $host $hand $chan $chan1 topic.14 $number
- return
- }
- set delete [lreplace $lines $current_place $current_place]
- set files [open $new_dir "w"]
- puts $files [join $delete "\n"]
- close $files
- set file [open $new_dir "r"]
- set data [read -nonewline $file]
- close $file
- if {$data == ""} {
- set files [open $new_dir "w"]
- close $files
- }
- blacktools:tell $nick $host $hand $chan $chan1 topic.10 $number
- }
- set {
- array set topicset [list]
-
- if {![regexp {^[0-9]} $number]} {
- blacktools:tell $nick $host $hand $chan $chan1 topic.11 none
- return
- }
- set file [open $new_dir "r"]
- set data [read -nonewline $file]
- close $file
- set lines [split $data "\n"]
- set counter -1
- set line_counter -1
- set current_place -1
- foreach line $lines {
- set line_counter [expr $line_counter + 1]
- set read_chan [lindex [split $line] 0]
- if {[string match -nocase $read_chan $chan]} {
- set counter [expr $counter + 1]
- set topicdel($counter) $line_counter
- }
- }
- foreach place [array names topicdel] {
- if {$place == [expr $number - 1]} {
- set current_place $topicdel($place)
- }
- }
- if {$current_place == "-1"} {
- blacktools:tell $nick $host $hand $chan $chan1 topic.15 $number
- return
- }
- set current_line [lindex $lines $current_place]
- set line [join [lrange [split $current_line] 1 end]]
- putquick "TOPIC $chan :Setting topic.."
- putserv "TOPIC $chan :$line"
- blacktools:tell $nick $host $hand $chan $chan1 topic.12 $number
- }
- lock {
- set gettopic [topic $chan]
- if {$gettopic == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 topic.16 none
- return
- }
- channel set $chan +topiclock
- channel set $chan topicset $gettopic
- blacktools:tell $nick $host $hand $chan $chan1 topic.17 none
- }
- unlock {
- if {![channel get $chan topiclock]} {
- blacktools:tell $nick $host $hand $chan $chan1 topic.18 none
- }
- channel set $chan -topiclock
- channel set $chan topicset ""
- blacktools:tell $nick $host $hand $chan $chan1 topic.19 none
- }
- }
- }
- proc topic:change {nick host hand chan arg} {
- global black
- set thetopic [channel get $chan topicset]
- set handle [nick2hand $nick]
- set getlang [string tolower [channel get $chan lang]]
- if {![botisop $chan]} { return }
- if {[isbotnick $nick]} { return }
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
- if {[channel get $chan topiclock]} {
- if {![matchattr $handle nm|M $chan]} {
- putserv "TOPIC $chan :$thetopic"
- if {[info exists black(say.$getlang.topic.20)]} {
- putserv "NOTICE $nick :$black(say.$getlang.topic.20)"
- }
- } else {
- channel set $chan topicset [topic $chan]
- }
- }
- }
- proc topiclock:verify {nick host hand chan args} {
- global black
- set onick [lindex $args 1]
- if {![validchan $chan]} { return }
- if {[isbotnick $onick] && [channel get $chan topiclock]} {
- if {[channel get $chan topicset] != ""} {
- set thetopic [topic $chan]
- set locktopic [channel get $chan topicset]
- if {$thetopic != $locktopic} {
- putserv "TOPIC $chan :$locktopic"
- }
- }
- }
- }
- proc topiclock:join {nick host hand chan} {
- global black
- if {![validchan $chan]} { return }
- if {![isbotnick $nick]} {
- return
- }
- if {[llength [chanlist $chan]] > 1} {
- return
- }
- utimer 5 [list topiclock:join:act $chan]
- }
- proc topiclock:join:act {chan} {
- global black
- if {![botisop $chan]} {
- return
- }
- if {[channel get $chan topiclock]} {
- if {[channel get $chan topicset] != ""} {
- set thetopic [topic $chan]
- set locktopic [channel get $chan topicset]
- if {$thetopic != $locktopic} {
- putserv "TOPIC $chan :$locktopic"
- }
- }
- }
- }
- ################################# Seen ###################################
- proc seen:save:2 {nick chan host type time staytimer reason} {
- global black username
- set seendir "scripts/BlackTools/FILES/$username.Seen.db"
- set lin 0
- set j 0
- set who "$type $chan $nick $host $time $staytimer $reason"
- set file [open $seendir "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
- foreach line $data {
- set lin [expr $lin +1]
- set userentry [lindex [split $line] 2]
- set chanentry [lindex [split $line] 1]
- if {[string equal -nocase $userentry $nick] && [string match -nocase $chanentry $chan]} {
- set joined [lindex [split $line] 0]
- if {$joined == "JOIN"} {
- set j [lindex [split $line] 4]
- if {![regexp {^[0-9]} $j] || ($j == "")} {
- set j 0
- }
- }
- set who "$type $chan $nick $host $time $j $reason"
- if {$line != ""} {
- set num [expr $lin - 1]
- set delete [lreplace $data $num $num]
- set files [open $seendir "w"]
- puts $files [join $delete "\n"]
- close $files
- }
- }
- }
- set file [open $seendir "r"]
- set data [read -nonewline $file]
- close $file
- if {$data == ""} {
- set files [open $seendir "w"]
- close $files
- }
- set file [open $seendir "a"]
- puts $file "$who"
- close $file
- }
- proc seen:save:1 {nick chan host type time staytimer} {
- global black username
- set seendir "scripts/BlackTools/FILES/$username.Seen.db"
- set lin 0
- set who "$type $chan $nick $host $time $staytimer"
- set file [open $seendir "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
- foreach line $data {
- set lin [expr $lin +1]
- set userentry [lindex [split $line] 2]
- set chanentry [lindex [split $line] 1]
- if {[string equal -nocase $userentry $nick] && [string match -nocase $chanentry $chan]} {
- if {$line != ""} {
- set num [expr $lin - 1]
- set delete [lreplace $data $num $num]
- set files [open $seendir "w"]
- puts $files [join $delete "\n"]
- close $files
- }
- }
- }
- set file [open $seendir "r"]
- set data [read -nonewline $file]
- close $file
- if {$data == ""} {
- set files [open $seendir "w"]
- close $files
- }
- set file [open $seendir "a"]
- puts $file "$who"
- close $file
- }
- proc seen:join {nick host hand chan} {
- global botnick username
- set seendir "scripts/BlackTools/FILES/$username.Seen.db"
- if {![validchan $chan]} { return}
- if {![channel get $chan seen]} {
- return
- }
- if {[isbotnick $nick]} { return }
- set time [unixtime]
- set host "*!$host"
- set type "JOIN"
- set staytimer "0"
- seen:save:1 $nick $chan $host $type $time $staytimer
- }
- proc seen:part {nick host hand chan arg} {
- global botnick username
- set seendir "scripts/BlackTools/FILES/$username.Seen.db"
- if {![validchan $chan]} { return }
- if {![channel get $chan seen]} {
- return
- }
- set time [unixtime]
- set staytimer "0"
- set type "PART"
- set reason [join [lrange [split $arg] 0 end]]
- if {$reason == ""} { set reason "No Reason" }
- set host "*!$host"
- if {[isbotnick $nick]} { return }
- seen:save:2 $nick $chan $host $type $time $staytimer $reason
- }
- proc seen:sign {nick host hand chan arg} {
- global botnick username
- set seendir "scripts/BlackTools/FILES/$username.Seen.db"
- if {![validchan $chan]} { return }
- if {![channel get $chan seen]} {
- return 0
- }
- set time [unixtime]
- set staytimer "0"
- set type "SIGN"
- set host "*!$host"
- set reason [join [lrange [split $arg] 0 end]]
- if {$reason == ""} { set reason "No Reason" }
- if {[isbotnick $nick]} { return }
- seen:save:2 $nick $chan $host $type $time $staytimer $reason
- }
- proc seen:kick {nick host hand chan kicked reason} {
- global botnick username
- set seendir "scripts/BlackTools/FILES/$username.Seen.db"
- if {![validchan $chan]} { return }
- if {![channel get $chan seen]} {
- return
- }
- set lin 0
- set j 0
- set time [unixtime]
- set hosted [getchanhost $kicked $chan]
- set hosted "*!$hosted"
- set reason [join [lrange [split $reason] 1 end]]
- if {$reason == ""} { set reason "No Reason" }
- if {[isbotnick $kicked]} { return }
- set who "KICK $chan $kicked $hosted $time 0 $reason"
- set file [open $seendir "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
- foreach line $data {
- set lin [expr $lin +1]
- set userentry [lindex [split $line] 2]
- set chanentry [lindex [split $line] 1]
- if {[string equal -nocase $kicked $userentry] && [string match -nocase $chanentry $chan]} {
- set joined [lindex [split $line] 0]
- if {$joined == "JOIN"} {
- set j [lindex [split $line] 4]
- if {![regexp {^[0-9]} $j] || ($j == "")} {
- set j 0
- }
- }
- set who "KICK $chan $kicked $hosted $time $j $reason"
- if {$line != ""} {
- set num [expr $lin - 1]
- set delete [lreplace $data $num $num]
- set files [open $seendir "w"]
- puts $files [join $delete "\n"]
- close $files
- }
- }
- }
- set file [open $seendir "r"]
- set data [read -nonewline $file]
- close $file
- if {$data == ""} {
- set files [open $seendir "w"]
- close $files
- }
- set file [open $seendir "a"]
- puts $file "$who"
- close $file
- }
- proc seen:split {nick host hand chan args} {
- global botnick username
- set seendir "scripts/BlackTools/FILES/$username.Seen.db"
- if {![validchan $chan]} { return }
- if {![channel get $chan seen]} {
- return
- }
- set time [unixtime]
- set staytimer "0"
- set type "SPLIT"
- set host "*!$host"
- set reason [join [lrange [split $args] 0 end]]
- if {[isbotnick $nick]} { return }
- seen:save:2 $nick $chan $host $type $time $staytimer $reason
- }
- proc seen:changenick {nick host hand chan newnick} {
- global botnick username
- set seendir "scripts/BlackTools/FILES/$username.Seen.db"
- if {![validchan $chan]} { return }
- if {![channel get $chan seen]} {
- return
- }
- set time [unixtime]
- set host "*!$host"
- set staytimer "0"
- set type "NICKCHANGE"
- if {[isbotnick $nick]} { return }
- seen:save:2 $nick $chan $host $type $time $staytimer $newnick
- }
- proc seenpublic {nick host hand chan arg} {
- global black
- if {![channel get $chan seen]} {
- return
- }
- set type 0
- set chan1 "$chan"
- set what [lindex [split $arg] 0]
- if {[regexp {^[&#]} $what] && [matchattr $hand nm|- $chan]} {
- set chan1 "$chan"
- set chan "$what"
- set what [lindex [split $arg] 1]
- }
- seen:process $nick $host $hand $chan $chan1 $what $type
- }
- proc seen:process {nick host hand chan chan1 what type} {
- global black count botnick username
- set seendir "scripts/BlackTools/FILES/$username.Seen.db"
- set number [scan $black(seenflood) %\[^:\]]
- set timer [scan $black(seenflood) %*\[^:\]:%s]
- set i 0
- set char(p) [lindex $black(cmdchar) 0]
- array set seensort [list]
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- if {($what == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 seen.1 none
- return
- }
- if {($what == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 seen.2 none
- return
- }
-
- if {![validchan $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
- return
- }
- if {![onchan $botnick $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
- return
- }
- foreach tmr [utimers] {
- if {[string match "*count(flood:$host:$chan)*" [join [lindex $tmr 1]]]} {
- killutimer [lindex $tmr 2]
- }
- }
- if {![info exists count(flood:$host:$chan)]} {
- set count(flood:$host:$chan) 0
- }
- incr count(flood:$host:$chan)
- utimer $timer [list unset count(flood:$host:$chan)]
- if {$count(flood:$host:$chan) == "$number"} {
- blacktools:tell $nick $host $hand $chan $chan1 seen.5 none
- return
- }
-
- if {[string equal -nocase $what $nick] && ($chan1 == $chan)} { blacktools:tell $nick $host $hand $chan $chan1 seen.6 $nick
- return
- }
- if {[onchan $what $chan]} { blacktools:tell $nick $host $hand $chan $chan1 seen.7 $what
- return
- }
- set file [open $seendir "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
- set length_data [llength $data]
- for {set j $length_data} {$j >= 0} {set j [expr $j - 1]} {
- set line [lindex $data $j]
- if {$line != ""} {
- set userentry [lindex [split $line] 2]
- set chanentry [lindex [split $line] 1]
- set host [lindex [split $line] 3]
- if {$what == "*!*@*"} { return 0 }
- if {([string equal -nocase $userentry $what] || [string match -nocase $what $userentry] || [string match -nocase $what $host]) && [string match -nocase $chanentry $chan]} {
- set i [expr $i +1]
- if {$i < 6} {
- lappend entry $userentry
- }
- set seenfound 1
-
- set host [string trim $host "*!~"]
- set tm [lindex [split $line] 4]
- set jointime [lindex [split $line] 5]
- set newnick [lindex [split $line] 6]
- set reason [join [lrange [split $line] 6 end]]
- if {!([regexp {^[0-9]} $jointime]) || ($jointime == "")} {
- set jointime 0
- set reason [join [lrange [split $line] 5 end]]
- }
- if {$reason == ""} { set reason "No Reason" }
- set output [duration [expr [unixtime] - $tm]]
- set staytime [expr [unixtime] - $jointime]
- set staytime [duration [expr $tm - $jointime]]
- set getlang [string tolower [channel get $chan lang]]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
- set date [clock format $tm -format %d.%m.]
- set hour [clock format $tm -format %H:%M]
-
- set top_seenlist ""
- set entry [lsort -unique $entry]
- set seensort($tm) $j
- foreach line [lsort -integer -decreasing [array names seensort]] {
- lappend top_seenlist $seensort($line)
- }
- set current_line [lindex $top_seenlist 0]
- set line [lindex $data $current_line]
-
- set latest_entry [lindex [split $line] 2]
- set host [lindex [split $line] 3]
- set host [string trim $host "*!~"]
- set tm [lindex [split $line] 4]
- set jointime [lindex [split $line] 5]
- set newnick [lindex [split $line] 6]
- set reason [join [lrange [split $line] 6 end]]
- if {!([regexp {^[0-9]} $jointime]) || ($jointime == "")} {
- set jointime 0
- set reason [lrange [split $line] 5 end]
- }
- if {$reason == ""} { set reason "No Reason" }
- set output [duration [expr [unixtime] - $tm]]
- set staytime [expr [unixtime] - $jointime]
- set staytime [duration [expr $tm - $jointime]]
- set getlang [string tolower [channel get $chan lang]]
- if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
- set date [clock format $tm -format %d.%m.]
- set hour [clock format $tm -format %H:%M]
-
- set replace(%latest%) $latest_entry
- set replace(%num%) [llength $entry]
- set replace(%entry%) "[join $entry ", "]"
- set replace(%host%) "$host"
- set replace(%output%) "$output"
- set replace(%date%) "($date $hour)"
- set replace(%newnick%) "$newnick"
- set replace(%userentry%) "$userentry"
- set replace(%chan%) "$chan"
- set replace(%reason%) "$reason"
- set replace(%staytime%) "$staytime"
- if {$jointime == "0"} { set staymsg "[string map [array get replace] $black(say.$getlang.seen.8)]"
- set replace(%staymsg%) "$staymsg"
- } else {
- set staymsg "[string map [array get replace] $black(say.$getlang.seen.9)]"
- set replace(%staymsg%) "$staymsg"
- }
- if {[llength $entry] > 1} {
- set found_many 1
- if {[lindex [split $line] 0] == "PART"} {
- set reply "[string map [array get replace] $black(say.$getlang.seen.21)]"
- }
- if {[lindex [split $line] 0] == "SIGN"} {
- set reply "[string map [array get replace] $black(say.$getlang.seen.22)]"
- }
- if {[lindex [split $line] 0] == "JOIN"} {
- if {[onchan $latest_entry $chan]} {
- set nowon "[string map [array get replace] $black(say.$getlang.seen.19)]"
- set replace(%nowon%) "$nowon"
- } else {
- set nowon "[string map [array get replace] $black(say.$getlang.seen.11)]"
- set replace(%nowon%) "$nowon"
- }
- set reply "[string map [array get replace] $black(say.$getlang.seen.23)]"
- }
- if {[lindex [split $line] 0] == "SPLIT"} {
- set reply "[string map [array get replace] $black(say.$getlang.seen.24)]"
- }
- if {[lindex [split $line] 0] == "KICK"} {
- set reply "[string map [array get replace] $black(say.$getlang.seen.25)]"
- }
- if {[lindex [split $line] 0] == "NICKCHANGE"} {
- if {[onchan $newnick $chan]} {
- set nowon "[string map [array get replace] $black(say.$getlang.seen.10)]"
- set replace(%nowon%) "$nowon"
- } else {
- set nowon "[string map [array get replace] $black(say.$getlang.seen.11)]"
- set replace(%nowon%) "$nowon"
- }
- set reply "[string map [array get replace] $black(say.$getlang.seen.26)]"
- }
- } else {
- if {[lindex [split $line] 0] == "PART"} {
- set reply "[string map [array get replace] $black(say.$getlang.seen.12)]"
- }
- if {[lindex [split $line] 0] == "SIGN"} {
- set reply "[string map [array get replace] $black(say.$getlang.seen.13)]"
- }
- if {[lindex [split $line] 0] == "JOIN"} {
- if {[onchan $userentry $chan]} {
- set nowon "[string map [array get replace] $black(say.$getlang.seen.19)]"
- set replace(%nowon%) "$nowon"
- } else {
- set nowon "[string map [array get replace] $black(say.$getlang.seen.11)]"
- set replace(%nowon%) "$nowon"
- }
- set reply "[string map [array get replace] $black(say.$getlang.seen.14)]"
- }
- if {[lindex [split $line] 0] == "SPLIT"} {
- set reply "[string map [array get replace] $black(say.$getlang.seen.15)]"
- }
- if {[lindex [split $line] 0] == "KICK"} {
- set reply "[string map [array get replace] $black(say.$getlang.seen.16)]"
- }
- if {[lindex [split $line] 0] == "NICKCHANGE"} {
- if {[onchan $newnick $chan]} {
- set nowon "[string map [array get replace] $black(say.$getlang.seen.10)]"
- set replace(%nowon%) "$nowon"
- } else {
- set nowon "[string map [array get replace] $black(say.$getlang.seen.11)]"
- set replace(%nowon%) "$nowon"
- }
- set reply "[string map [array get replace] $black(say.$getlang.seen.17)]"
- }
- }
- }
- set method "NOTICE"
- set onwho "$nick"
- set how [channel get $chan seen-method]
-
- switch [string tolower $how] {
- notice {
- set method "NOTICE"
- set onwho "$nick"
- }
- privmsg {
- set method "PRIVMSG"
- set onwho "$chan1"
- }
- }
- }
- }
- if {[info exists reply]} {
- puthelp "$method $onwho :$reply"
- }
- if {![info exists seenfound]} {
- blacktools:tell $nick $host $hand $chan $chan1 seen.18 $what
- }
- }
- proc seen:entry:delete {minute hour day month year} {
- global black username
- set seendir "scripts/BlackTools/FILES/$username.Seen.db"
- set file [open $seendir "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
- set counter 0
- putlog "\[BlackTools\] Checking for expired seen records.."
- foreach line $data {
- set tm [lindex [split $line] 4]
- set read_days [expr [expr [expr [expr [unixtime] - $tm] / 60]] / 1440]
- if {$read_days >= $black(seen:expire:time)} {
- set counter [expr $counter + 1]
- lappend expire_list $tm
- }
- }
- if {[info exists expire_list]} {
- seen:delete:action $counter $expire_list
- }
- }
- proc seen:delete:action {counter list} {
- global black username
- set seendir "scripts/BlackTools/FILES/$username.Seen.db"
- set list [join $list]
- foreach tm $list {
- if {$tm != ""} {
- set file [open $seendir "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
- set i [lsearch -glob $data "* $tm *"]
- if {$i > -1} {
- set line [lindex $data $i]
- set delete [lreplace $data $i $i]
- set file [open $seendir "w"]
- puts $file [join $delete "\n"]
- close $file
- }
- }
- }
- putlog "\[BlackTools\] Found $counter expired SEEN records."
- }
- ############################### Greet #####################################
- proc greetpublic {nick host hand chan arg} {
- global black
- set who [lindex [split $arg] 0]
- set type 0
- set chan1 "$chan"
- set greet [join [lrange [split $arg] 1 end]]
- set number [lindex [split $arg] 1]
- if {[regexp {^[&#]} $who] && [matchattr $hand nm|M $who]} {
- set chan "$who"
- set who [lindex [split $arg] 1]
- set greet [join [lrange [split $arg] 2 end]]
- set number [lindex [split $arg] 2]
- }
- greet:process $who $greet $number $type $nick $host $hand $chan $chan1
- }
- proc greet:process {who greet number type nick host hand chan chan1} {
- global botnick black username
- set char(p) [lindex $black(cmdchar) 0]
- set new_dir "scripts/BlackTools/FILES/$username.greets.txt"
-
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- if {($who == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 greet.1 none
- return
- }
- if {($who == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 greet.2 none
- return
- }
- if {![validchan $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
- return
- }
- if {![onchan $botnick $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
- return
- }
- switch $who {
- on {
- channel set $chan +greet
- blacktools:tell $nick $host $hand $chan $chan1 greet.3 none
- }
- off {
- channel set $chan -greet
- blacktools:tell $nick $host $hand $chan $chan1 greet.4 none
- }
- add {
- set counter -1
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set current -1
- foreach line $data {
- set counter [expr $counter + 1]
- set channel [lindex [split $line] 0]
- if {[string equal -nocase $chan $channel]} {
- set status [lindex [split $line] 1]
- if {$status == "1"} {
- set message [join [lrange [split $line] 2 end]]
- set delete [lreplace $data $counter $counter]
- set file [open $new_dir "w"]
- puts $file [join $delete "\n"]
- close $file
- set file [open $new_dir a]
- puts $file "$chan 0 $message"
- close $file
- }
- }
- }
- set file [open $new_dir a]
- puts $file "$chan 1 $greet"
- close $file
-
- blacktools:tell $nick $host $hand $chan $chan1 greet.5 none
- blacktools:tell $nick $host $hand $chan $chan1 greet.6 $greet
- }
- list {
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set i 0
- set found_it 0
- if {$data == ""} { blacktools:tell $nick $host $hand $chan $chan1 greet.7 none
- return
- }
- blacktools:tell $nick $host $hand $chan $chan1 greet.8 none
- foreach mes $data {
- set channel [lindex [split $mes] 0]
- if {[string equal -nocase $channel $chan]} {
- set i [expr $i +1]
- set found_it 1
- set message [join [lrange [split $mes] 2 end]]
- set status [lindex [split $mes] 1]
- if {$status == 1} {
- blacktools:tell $nick $host $hand $chan $chan1 greet.6 "\002\[ON\]\002 $i. $message"
- } else {
- blacktools:tell $nick $host $hand $chan $chan1 greet.6 "\[OFF\] $i. $message"
- }
- }
- }
- if {$found_it == "0"} {
- blacktools:tell $nick $host $hand $chan $chan1 greet.7 none
- } else {
- blacktools:tell $nick $host $hand $chan $chan1 greet.11 none
- }
- }
- del {
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set counter 0
-
- foreach line $data {
- set the_greet [join [lrange [split $line] 2 end]]
- set channel [lindex [split $line] 0]
- if {[string equal -nocase $channel $chan] && [string match -nocase $greet $the_greet]} {
- set counter [expr $counter + 1]
- }
- }
- for {set j 0} {$j < $counter} {incr j} {
-
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set i [lsearch -glob $data "* $greet"]
- if {$i > -1} {
- set line [lindex $data $i]
- set delete [lreplace $data $i $i]
- set file [open $new_dir "w"]
- puts $file [join $delete "\n"]
- close $file
- }
- }
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- if {$w == ""} {
- set file [open $new_dir "w"]
- close $file
- }
- blacktools:tell $nick $host $hand $chan $chan1 greet.10 $counter
- }
- set {
- set counter -1
- set list_counter 0
- array set greetset [list]
- set current_place -1
- set last_message ""
- set last_place -1
- if {$number == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 greet.12 none
- return
- }
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- foreach line $data {
- set counter [expr $counter + 1]
- set channel [lindex [split $line] 0]
- if {[string equal -nocase $channel $chan]} {
- set list_counter [expr $list_counter + 1]
- set greetset($list_counter) $counter
-
- }
- }
- foreach place [array names greetset] {
- if {$place == $number} {
- set current_place $greetset($place)
- }
- }
- if {$current_place == "-1"} {
- blacktools:tell $nick $host $hand $chan $chan1 greet.13 none
- return
- }
- set current_line [lindex $data $current_place]
- set status [lindex [split $current_line] 1]
- if {$status == "1"} {
- blacktools:tell $nick $host $hand $chan $chan1 greet.14 none
- }
- set current_message [join [lrange [split $current_line] 2 end]]
-
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set counter -1
- foreach line $data {
- set counter [expr $counter + 1]
- set channel [lindex [split $line] 0]
- set message [join [lrange [split $line] 2 end]]
- if {[string equal -nocase $chan $channel]} {
- set status [lindex [split $line] 1]
- if {$status == "1"} {
- set delete [lreplace $data $counter $counter]
- set last_place $counter
- set last_message $message
- set file [open $new_dir "w"]
- puts $file [join $delete "\n"]
- close $file
- }
- }
- }
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set insert [linsert $data $last_place "$chan 0 $last_message"]
- set file [open $new_dir w]
- puts $file [join $insert "\n"]
- close $file
-
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
-
-
- set delete [lreplace $data $current_place $current_place]
- set file [open $new_dir "w"]
- puts $file [join $delete "\n"]
- close $file
-
-
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
-
- set insert [linsert $data $current_place "$chan 1 $current_message"]
- set file [open $new_dir w]
- puts $file [join $insert "\n"]
- close $file
-
- blacktools:tell $nick $host $hand $chan $chan1 greet.15 $number
- }
- }
- }
- proc greetpublic:join {nick host hand chan} {
- global black username count
- set new_dir "scripts/BlackTools/FILES/$username.greets.txt"
- set current_greet ""
- if {![validchan $chan]} { return }
- if {[channel get $chan greet]} {
- if {[isbotnick $nick]} { return }
- if {[info exists black(turnOnFlood:$chan)]} {
- return
- }
- set replace(%nick%) $nick
- set file [open $new_dir "r"]
- set data [read -nonewline $file]
- close $file
- if {$data == ""} { return }
- set lines [split $data "\n"]
- foreach line $lines {
- set channel [lindex [split $line] 0]
- set status [lindex [split $line] 1]
- if {[string equal -nocase $channel $chan] && ($status == "1")} {
- set message [join [lrange [split $line] 2 end]]
- set current_greet $message
- }
- }
- set the_message [string map [array get replace] $current_greet]
- set split_message [split $the_message "~"]
- foreach message $split_message {
- if {$black(howgreet) == "1"} {
- puthelp "NOTICE $nick :$message"
- } else { puthelp "PRIVMSG $nick :$message" }
- }
- }
- }
- ################################ Leave ###################################
- proc leavepublic {nick host hand chan arg} {
- global black
- set who [lindex [split $arg] 0]
- set type 0
- set chan1 "$chan"
- set leave [join [lrange [split $arg] 1 end]]
- set number [lindex [split $arg] 1]
- if {[regexp {^[&#]} $who] && [matchattr $hand nm|M $who]} {
- set chan "$who"
- set who [lindex [split $arg] 1]
- set leave [join [lrange [split $arg] 2 end]]
- set number [lindex [split $arg] 2]
- }
- leave:process $who $leave $number $type $nick $host $hand $chan $chan1
- }
- proc leave:process {who leave number type nick host hand chan chan1} {
- global botnick black username
- set char(p) [lindex $black(cmdchar) 0]
- set new_dir "scripts/BlackTools/FILES/$username.leave.txt"
-
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- if {($who == "") && ($type == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 leave.1 none
- return
- }
- if {($who == "") && ($type == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 leave.2 none
- return
- }
- if {![validchan $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
- return
- }
- if {![onchan $botnick $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
- return
- }
- switch $who {
- on {
- channel set $chan +leave
- blacktools:tell $nick $host $hand $chan $chan1 leave.3 none
- }
- off {
- channel set $chan -leave
- blacktools:tell $nick $host $hand $chan $chan1 leave.4 none
- }
- add {
- set counter -1
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set current -1
- foreach line $data {
- set counter [expr $counter + 1]
- set channel [lindex [split $line] 0]
- if {[string equal -nocase $chan $channel]} {
- set status [lindex [split $line] 1]
- if {$status == "1"} {
- set message [join [lrange [split $line] 2 end]]
- set delete [lreplace $data $counter $counter]
- set file [open $new_dir "w"]
- puts $file [join $delete "\n"]
- close $file
- set file [open $new_dir a]
- puts $file "$chan 0 $message"
- close $file
- }
- }
- }
- set file [open $new_dir a]
- puts $file "$chan 1 $leave"
- close $file
-
- blacktools:tell $nick $host $hand $chan $chan1 leave.5 none
- blacktools:tell $nick $host $hand $chan $chan1 leave.6 $leave
- }
- list {
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set i 0
- set found_it 0
- if {$data == ""} { blacktools:tell $nick $host $hand $chan $chan1 leave.7 none
- return
- }
- blacktools:tell $nick $host $hand $chan $chan1 leave.8 none
- foreach mes $data {
- set channel [lindex [split $mes] 0]
- if {[string equal -nocase $channel $chan]} {
- set i [expr $i +1]
- set found_it 1
- set message [join [lrange [split $mes] 2 end]]
- set status [lindex [split $mes] 1]
- if {$status == 1} {
- blacktools:tell $nick $host $hand $chan $chan1 leave.6 "\002\[ON\]\002 $i. $message"
- } else {
- blacktools:tell $nick $host $hand $chan $chan1 leave.6 "\[OFF\] $i. $message"
- }
- }
- }
- if {$found_it == "0"} {
- blacktools:tell $nick $host $hand $chan $chan1 leave.7 none
- } else {
- blacktools:tell $nick $host $hand $chan $chan1 leave.11 none
- }
- }
- del {
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set counter 0
-
- foreach line $data {
- set the_leave [join [lrange [split $line] 2 end]]
- set channel [lindex [split $line] 0]
- if {[string equal -nocase $channel $chan] && [string match -nocase $leave $the_leave]} {
- set counter [expr $counter + 1]
- }
- }
- for {set j 0} {$j < $counter} {incr j} {
-
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set i [lsearch -glob $data "* $leave"]
- if {$i > -1} {
- set line [lindex $data $i]
- set delete [lreplace $data $i $i]
- set file [open $new_dir "w"]
- puts $file [join $delete "\n"]
- close $file
- }
- }
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- if {$w == ""} {
- set file [open $new_dir "w"]
- close $file
- }
- blacktools:tell $nick $host $hand $chan $chan1 leave.10 $counter
- }
- set {
- set counter -1
- set list_counter 0
- array set leaveset [list]
- set current_place -1
- set last_message ""
- set last_place -1
- if {$number == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 leave.12 none
- return
- }
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- foreach line $data {
- set counter [expr $counter + 1]
- set channel [lindex [split $line] 0]
- if {[string equal -nocase $channel $chan]} {
- set list_counter [expr $list_counter + 1]
- set leaveset($list_counter) $counter
-
- }
- }
- foreach place [array names leaveset] {
- if {$place == $number} {
- set current_place $leaveset($place)
- }
- }
- if {$current_place == "-1"} {
- blacktools:tell $nick $host $hand $chan $chan1 leave.13 none
- return
- }
- set current_line [lindex $data $current_place]
- set status [lindex [split $current_line] 1]
- if {$status == "1"} {
- blacktools:tell $nick $host $hand $chan $chan1 leave.14 none
- }
- set current_message [join [lrange [split $current_line] 2 end]]
-
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- if {$data == ""} {
- set file [open $new_dir "w"]
- close $file
- }
-
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set counter -1
- foreach line $data {
- set counter [expr $counter + 1]
- set channel [lindex [split $line] 0]
- set message [join [lrange [split $line] 2 end]]
- if {[string equal -nocase $chan $channel]} {
- set status [lindex [split $line] 1]
- if {$status == "1"} {
- set delete [lreplace $data $counter $counter]
- set last_place $counter
- set last_message $message
- set file [open $new_dir "w"]
- puts $file [join $delete "\n"]
- close $file
- }
- }
- }
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
- set insert [linsert $data $last_place "$chan 0 $last_message"]
- set file [open $new_dir w]
- puts $file [join $insert "\n"]
- close $file
-
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
-
- set delete [lreplace $data $current_place $current_place]
- set file [open $new_dir "w"]
- puts $file [join $delete "\n"]
- close $file
-
- set file [open $new_dir "r"]
- set w [read -nonewline $file]
- close $file
- set data [split $w "\n"]
-
- set insert [linsert $data $current_place "$chan 1 $current_message"]
- set file [open $new_dir w]
- puts $file [join $insert "\n"]
- close $file
-
- blacktools:tell $nick $host $hand $chan $chan1 leave.15 $number
- }
- }
- }
- proc leavepublic:part {nick host hand chan args} {
- global black username count
- set new_dir "scripts/BlackTools/FILES/$username.leave.txt"
- set current_leave ""
- set number [scan $black(leaveflood) %\[^:\]]
- set time [scan $black(leaveflood) %*\[^:\]:%s]
- if {![validchan $chan]} { return }
- if {[channel get $chan leave]} {
- if {[isbotnick $nick]} { return }
- foreach tmr [utimers] {
- if {[string match "*count(leaveflood:$chan)*" [join [lindex $tmr 1]]]} {
- killutimer [lindex $tmr 2]
- }
- }
- if {[info exists black(leavestopped:$chan)]} {
- return
- }
- if {![info exists count(leaveflood:$chan)]} {
- set count(leaveflood:$chan) 0
- }
- incr count(leaveflood:$chan)
- utimer $time [list unset count(leaveflood:$chan)]
- if {$count(leaveflood:$chan) >= $number} {
- set black(leavestopped:$chan) 1
- utimer 60 [list unset black(leavestopped:$chan)]
- return
- }
- set replace(%nick%) $nick
- set file [open $new_dir "r"]
- set data [read -nonewline $file]
- close $file
- if {$data == ""} { return }
- set lines [split $data "\n"]
- foreach line $lines {
- set channel [lindex [split $line] 0]
- set status [lindex [split $line] 1]
- if {[string equal -nocase $channel $chan] && ($status == "1")} {
- set message [join [lrange [split $line] 2 end]]
- set current_greet $message
- }
- }
- set the_message [string map [array get replace] $current_greet]
- set split_message [split $the_message "~"]
- foreach message $split_message {
- if {$black(howleave) == "1"} {
- puthelp "NOTICE $nick :$message"
- } else { puthelp "PRIVMSG $nick :$message" }
- }
- }
- }
- ################################ Idle ###################################
- proc antidlepublic {nick host hand chan arg} {
- global black
- set char(p) [lindex $black(cmdchar) 0]
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- set type1 0
- set chan1 "$chan"
- set why [lindex [split $arg] 0]
- set type [lindex [split $arg] 1]
- set user [lindex [split $arg] 1]
- set host [lindex [split $arg] 2]
- if {[regexp {^[&#]} $why] && [matchattr $hand nm|M $why]} {
- set chan "$why"
- set why [lindex [split $arg] 1]
- set type [lindex [split $arg] 2]
- set user [lindex [split $arg] 2]
- set host [lindex [split $arg] 3]
- }
- antidle:process $why $type $type1 $user $host $nick $hand $chan $chan1
- }
- proc antidle:process {why type type1 user host nick hand chan chan1} {
- global botnick black
- set flag "-|f"
- set char(p) [lindex $black(cmdchar) 0]
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- set handle [nick2hand $user]
-
- if {($why == "") && ($type1 == "0")} {
- blacktools:tell $nick $host $hand $chan $chan1 idle.1 none
- return
- }
- if {($why == "") && ($type1 == "1")} {
- blacktools:tell $nick $host $hand $chan $chan1 idle.3 none
- return
- }
- if {![validchan $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
- return
- }
- if {![onchan $botnick $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
- return
- }
- switch $why {
- on {
- channel set $chan +antidle
- blacktools:tell $nick $host $hand $chan $chan1 idle.7 none
- }
- off {
- channel set $chan -antidle
- blacktools:tell $nick $host $hand $chan $chan1 idle.8 none
- }
- op {
- if {$type == ""} { blacktools:tell $nick $host $hand $chan $chan1 idle.9 none
- return
- }
- if {[string match -nocase $type "on"]} {
- if {[channel get $chan antidle]} { set antidle "on" } else { set antidle "off"}
- if {$antidle == "off"} { blacktools:tell $nick $host $hand $chan $chan1 idle.10 none
- return
- }
- channel set $chan +antididle
- blacktools:tell $nick $host $hand $chan $chan1 idle.11 none
- }
- if {[string match -nocase $type "off"]} {
- if {[channel get $chan antidle]} { set antidle "on" } else { set antidle "off"}
- if {$antidle == "off"} { blacktools:tell $nick $host $hand $chan $chan1 idle.10 none
- return
- }
- channel set $chan -antididle
- blacktools:tell $nick $host $hand $chan $chan1 idle.12 none
- }
- }
- voice {
- if {$type == ""} { blacktools:tell $nick $host $hand $chan $chan1 idle.13 none
- return
- }
- if {[string match -nocase $type "on"]} {
- if {[channel get $chan antidle]} { set antidle "on" } else { set antidle "off"}
- if {$antidle == "off"} { blacktools:tell $nick $host $hand $chan $chan1 idle.10 none
- return
- }
- channel set $chan +antividle
- blacktools:tell $nick $host $hand $chan $chan1 idle.14 none
- }
- if {[string match -nocase $type "off"]} {
- if {[channel get $chan antidle]} { set antidle "on" } else { set antidle "off"}
- if {$antidle == "off"} { blacktools:tell $nick $host $hand $chan $chan1 idle.10 none
- return
- }
- channel set $chan -antividle
- blacktools:tell $nick $host $hand $chan $chan1 idle.15 none
- }
- }
- add {
- if {$user == ""} { blacktools:tell $nick $host $hand $chan $chan1 idle.16 none
- return
- }
- if {[onchan $user $chan]} {
- set getuser [nick2hand $user]
- if {$getuser != "*"} {
- set user $getuser
- }
- }
- if {[validuser $user]} {
- chattr $user $flag $chan
- blacktools:tell $nick $host $hand $chan $chan1 idle.18 $user
- } else {
- set hosts [getchanhost $user $chan]
- set uhost "*!*@[lindex [split $hosts @] 1]"
- adduser $user $uhost
- chattr $user $flag $chan
- blacktools:tell $nick $host $hand $chan $chan1 idle.19 "$user $uhost"
- }
- }
- list {
- set list [userlist "-|f" $chan]
- blacktools:tell $nick $host $hand $chan $chan1 idle.20 "none"
- if {$list == ""} {set list "NONE"}
- blacktools:tell $nick $host $hand $chan $chan1 idle.21 "$list"
- }
- del {
- if {[onchan $user $chan]} {
- set getuser [nick2hand $user]
- if {$getuser != "*"} {
- set user $getuser
- }
- }
- if {![validuser $user]} {
- blacktools:tell $nick $host $hand $chan $chan1 idle.22 "$user"
- return
- }
- if {![matchattr $user "-|f" $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 idle.23 "$user"
- return
- }
- chattr $user -|-f $chan
- blacktools:tell $nick $host $hand $chan $chan1 idle.24 "$user"
- }
- }
- }
- proc idlewhoispublic {min hour day mon year} {
- global black botnick
- if {([scan $min %d]+([scan $hour %d]*60)) % $black(idleinterval) == 0} {
- if {[info exists black(idle_chans)]} {
- unset black(idle_chans)
- }
- foreach chan [channels] {
- if {[channel get $chan antidle] && [botisop $chan]} {
- lappend black(idle_chans) $chan
- }
- }
- if {[info exists black(idle_chans)]} {
- black:check:idle
- }
- }
- }
- proc black:check:idle {} {
- global black botnick
- foreach chan $black(idle_chans) {
- putlog "\[BlackTools\] Scanning for idle on $chan"
- foreach user [chanlist $chan] {
- set handle [nick2hand $user]
- if {[isop $user $chan] || [isvoice $user $chan]} {
- if {$user != $botnick} {
- putserv "WHOIS $user $user"
- }
- }
- }
- }
- bind raw - 317 idleprocespublic
- }
- proc idleprocespublic {nick int arg} {
- global black
- set nick [string tolower [lindex $arg 1]]
- set handle [nick2hand $nick]
- set idler [string tolower [lindex $arg 2]]
- set minutesidle [expr $idler / 60]
- foreach chan $black(idle_chans) {
- if {[onchan $nick $chan]} {
- set idlevoicetime [channel get $chan idlevoicemax]
- if {$idlevoicetime == "0"} { set idlevoicetime "$black(idlevoicemax)" }
- set idleoptime [channel get $chan idleopmax]
- if {$idleoptime == "0"} { set idleoptime "$black(idleopmax)" }
- if {[channel get $chan antividle]} {
- if {![matchattr $handle "-|gf" $chan]} {
- if {$minutesidle > $idlevoicetime} {
- putquick "MODE $chan -v $nick"
- }
- }
- }
- if {[channel get $chan antididle]} {
- if {![matchattr $handle "-|af" $chan]} {
- if {$minutesidle > $idleoptime} {
- putquick "MODE $chan -o $nick"
- }
- }
- }
- }
- }
- # unbind raw - 317 idleprocespublic
- }
- ##################################Auto User Expire ################################
- proc user:autoexpire {minute hour day month year} {
- global black
- set counter 0
- set max_time [expr 86400 * $black(user_expire_time)]
- foreach user [userlist] {
- set laston [getuser $user laston]
- if {$laston == ""} {
- set laston [getuser $user XTRA created]
- } else {
- set laston [lindex $laston 0]
- }
- set user_time [expr [unixtime] - $laston]
- if {$user_time > $max_time} {
- set counter [expr $counter + 1]
- deluser $user
- }
- }
- putlog "\[BlackTools\] User Auto Expire : Found $counter expired users."
- }
- ######################################### AntiBotIdle #############################
- proc botidlepublic {nick host hand chan arg} {
- global black botnick username
- set sdir "scripts/BlackTools/FILES/$username.status.txt"
- set what [lindex [split $arg] 0]
- set lin 0
- set chan1 "$chan"
- set char(p) [lindex $black(cmdchar) 0]
- if {[string match -nocase "none" "$char(p)"]} {
- set char(p) ""
- }
- if {$what == ""} { blacktools:tell $nick $host $hand $chan $chan1 antibotidle.1 none
- return
- }
- botidle:process $nick $host $hand $chan $chan1 $what
- }
- proc botidle:process {nick host hand chan chan1 what} {
- global botnick black sdir username
- set lin 0
- switch -exact -- [string tolower $what] {
- on {
- set type "antibotidle:module ON"
- foreach tmr [timers] {
- if {[string match "*antibotidle:module*" [join [lindex $tmr 1]]]} {
- blacktools:tell $nick $host $hand $chan $chan1 antibotidle.3 none
- return
- }
- }
- set file [open $sdir "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
- foreach line $data {
- set lin [expr $lin +1]
- set who [lindex [split $line] 0]
- set stats [lindex [split $line] 1]
- if {[string match -nocase "antibotidle:module" $who]} {
- if {$line != ""} {
- set num [expr $lin - 1]
- set delete [lreplace $data $num $num]
- set files [open $sdir "w"]
- puts $files [join $delete "\n"]
- close $files
- }
- }
- }
- set file [open $sdir "r"]
- set data [read -nonewline $file]
- close $file
- if {$data == ""} {
- set files [open $sdir "w"]
- close $files
- }
- set file [open $sdir "a"]
- puts $file "$type"
- close $file
- blacktools:tell $nick $host $hand $chan $chan1 antibotidle.4 none
- timer $black(noidlemax) antibotidle:module
- set antibotidle:module_running 1
- }
- off {
- blacktools:tell $nick $host $hand $chan $chan1 antibotidle.5 none
- set type "antibotidle:module OFF"
- foreach tmr [timers] {
- if {[string match "*antibotidle:module*" [join [lindex $tmr 1]]]} {
- killtimer [lindex $tmr 2]
- }
- }
- set file [open $sdir "r"]
- set database [read -nonewline $file]
- close $file
- set data [split $database "\n"]
- foreach line $data {
- set lin [expr $lin +1]
- set who [lindex [split $line] 0]
- set stats [lindex [split $line] 1]
- if {[string match -nocase "antibotidle:module" $who]} {
- if {$line != ""} {
- set num [expr $lin - 1]
- set delete [lreplace $data $num $num]
- set files [open $sdir "w"]
- puts $files [join $delete "\n"]
- close $files
- }
- }
- }
- set file [open $sdir "r"]
- set data [read -nonewline $file]
- close $file
- if {$data == ""} {
- set files [open $sdir "w"]
- close $files
- }
- set file [open $sdir "a"]
- puts $file "$type"
- close $file
- if {[info exists antibotidle:module_running]} {
- unset antibotidle:module_running
- }
- }
- }
- }
- proc antibotidle:module {} {
- global black
- putquick "PRIVMSG $black(noobject) :"
- timer $black(noidlemax) antibotidle:module
- return
- }
- ################################## next #######################################
- proc black:next:join {nick host hand chan} {
- global black
- set counter 0
- set time [unixtime]
- set handle [nick2hand $nick]
- set lang [channel get $chan lang]
- if {$lang == ""} { set lang [string tolower $black(default_lang)] }
- if {[channel get $chan next]} {
- if {[matchattr $handle $black(exceptflags) $chan]} {
- putserv "MODE $chan +v $nick"
- return
- }
- if {[isbotnick $nick]} {
- black:next:joincheck $chan
- return
- }
- if {[info exists black(next:$chan:list)]} {
- if {[lsearch -exact [string tolower $black(next:$chan:list)] [string tolower $nick]] == -1} {
- set black(next:$chan:list) [linsert $black(next:$chan:list) end $nick]
- set black(next:$chan:$nick:time) $time
- }
- } else {
- set black(next:$chan:list) $nick
- set black(next:$chan:$nick:time) $time
- }
- foreach name $black(next:$chan:list) {
- set get_hand [nick2hand $name]
-
- if {$name != ""} {
- if {![matchattr $get_hand $black(exceptflags) $chan]} {
- if {[onchan $name $chan]} {
- set counter [expr $counter +1]
- }
- }
- }
- }
- set backchan [channel get $chan next-backchan]
- set replace(%counter%) $counter
- set replace(%nick%) $nick
- set replace(%chan%) $chan
- if {($backchan != "") && [validchan $backchan]} {
- set message [string map [array get replace] $black(say.$lang.next.6)]
- puthelp "NOTICE $backchan :$message"
- }
- set message [string map [array get replace] $black(say.$lang.next.1)]
- puthelp "NOTICE $nick :$message"
- }
- }
- proc black:next:clear:all {nick chan} {
- global black
- if {[lsearch -exact [string tolower $black(next:$chan:list)] [string tolower $nick]] > -1} {
- set position [lsearch -exact [string tolower $black(next:$chan:list)] [string tolower $nick]]
- set black(next:$chan:list) [lreplace $black(next:$chan:list) $position $position]
- }
- if {[info exists black(next:$chan:$nick:time)]} {
- unset black(next:$chan:$nick:time)
- }
-
- if {[info exists black(next:$chan:list)]} {
- if {$black(next:$chan:list) == ""} {
- unset black(next:$chan:list)
- }
- }
- }
- proc black:next:clear {nick chan} {
- global black
- if {[lsearch -exact [string tolower $black(next:$chan:list)] [string tolower $nick]] > -1} {
- set position [lsearch -exact [string tolower $black(next:$chan:list)] [string tolower $nick]]
- set black(next:$chan:list) [lreplace $black(next:$chan:list) $position $position]
- }
- if {[info exists black(next:$chan:$nick:time)]} {
- unset black(next:$chan:$nick:time)
- }
- }
- proc black:next:joincheck {chan} {
- global black
- if {[info exists black(next:$chan:list)]} {
- foreach user [join $black(next:$chan:list)] {
- if {(![onchan $user $chan]) || [isvoice $user $chan] || [isop $user $chan]} {
- black:next:clear:all $user $chan
- }
- }
- }
- }
- proc black:next:part {nick host hand chan arg} {
- global black
- if {![validchan $chan]} { return }
- if {[channel get $chan next]} {
- if {![info exists black(next:$chan:list)]} {
- return
- }
- black:next:clear:all $nick $chan
- }
- }
- proc black:next:sign {nick host hand chan arg} {
- global black
- if {[channel get $chan next]} {
- if {![info exists black(next:$chan:list)]} {
- return
- }
- black:next:clear:all $nick $chan
- }
- }
- proc black:next:split {nick host hand chan args} {
- global black
- if {[channel get $chan next]} {
- if {![info exists black(next:$chan:list)]} {
- return
- }
- black:next:clear:all $nick $chan
- }
- }
- proc black:next:kick {nick host hand chan kicked arg} {
- global black
- if {[channel get $chan next]} {
- if {![info exists black(next:$chan:list)]} {
- return
- }
- black:next:clear:all $kicked $chan
- }
- }
- proc black:next:mode {nick host hand chan moded mod_nick} {
- global black
- if {[channel get $chan next]} {
- if {($moded == "+v") || ($moded == "+o")} {
- if {![info exists black(next:$chan:list)]} {
- return
- }
- black:next:clear:all $mod_nick $chan
- }
- }
- }
- proc black:next:chnick {nick host hand chan newnick} {
- global black
- if {[channel get $chan next]} {
- if {[info exists black(next:$chan:served)]} {
- if {[lsearch -exact [string tolower $black(next:$chan:served)] [string tolower $nick]] > -1} {
- set position [lsearch -exact [string tolower $black(next:$chan:served)] [string tolower $nick]]
- set black(next:$chan:served) [lreplace $black(next:$chan:served) $position $position]
- set black(next:$chan:served) [linsert $black(next:$chan:served) $position $newnick]
- }
- }
- if {[info exists black(next:$chan:list)]} {
- if {[lsearch -exact [string tolower $black(next:$chan:list)] [string tolower $nick]] > -1} {
- set position [lsearch -exact [string tolower $black(next:$chan:list)] [string tolower $nick]]
- set black(next:$chan:list) [lreplace $black(next:$chan:list) $position $position]
- set black(next:$chan:list) [linsert $black(next:$chan:list) $position $newnick]
- set black(next:$chan:$newnick:time) $black(next:$chan:$nick:time)
- }
- }
- }
- }
- proc nextpublic:cmd {nick host hand chan arg} {
- global black
- set option [lindex [split $arg] 0]
- set chan1 $chan
- foreach c [channels] {
- set backchan [channel get $c next-backchan]
- if {[string match -nocase $chan $backchan] && [channel get $c next]} {
- set chan "$c"
-
- }
- }
- nextpublic:process $nick $host $hand $chan $chan1 $option
- }
- proc nextpublic:process {nick host hand chan chan1 option} {
- global black
-
- if {![channel get $chan next]} {
- return
- }
- if {$option != ""} {
- switch -exact -- [string tolower $option] {
- list {
- set counter 0
- blacktools:tell $nick $host $hand $chan $chan1 next.7 none
- if {![info exists black(next:$chan:list)]} {
- blacktools:tell $nick $host $hand $chan $chan1 next.8 none
- return
- }
- if {$black(next:$chan:list) == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 next.8 none
- return
- }
- foreach name $black(next:$chan:list) {
- if {$name != ""} {
- set get_hand [nick2hand $name]
- if {![matchattr $get_hand $black(exceptflags) $chan]} {
- set counter [expr $counter + 1]
- lappend field_name "$counter. $name "
- }
- }
- }
- if {![info exists field_name]} {
- blacktools:tell $nick $host $hand $chan $chan1 next.8 none
- return
- }
- blacktools:tell $nick $host $hand $chan $chan1 next.9 [join $field_name]
- }
- }
- return
- }
- if {![info exists black(next:$chan:list)]} {
- blacktools:tell $nick $host $hand $chan $chan1 next.10 none
- return
- }
- if {[llength black(next:$chan:list)] < 0} {
- blacktools:tell $nick $host $hand $chan $chan1 next.10 none
- return
- }
- set current_nick [lindex $black(next:$chan:list) 0]
- set backchan [channel get $chan next-backchan]
- set lang [channel get $chan lang]
- if {$lang == ""} { set lang [string tolower $black(default_lang)] }
- set replace(%current%) $current_nick
- set replace(%nick%) $nick
- set replace(%hand%) $hand
- set message [string map [array get replace] $black(say.$lang.next.11)]
- if {($backchan != "") && [validchan $backchan]} {
- puthelp "PRIVMSG $backchan :$message"
- }
- set time [duration [expr [unixtime] - $black(next:$chan:$current_nick:time)]]
- set message_1 [string map [array get replace] $black(say.$lang.next.2)]
- puthelp "NOTICE $current_nick :$message_1"
- blacktools:tell $nick $host $hand $chan $chan1 next.3 "$current_nick $time"
- black:next:clear $current_nick $chan
- putserv "MODE $chan +v $current_nick"
-
- if {[info exists black(next:$chan:served)]} {
- if {[lsearch -exact [string tolower $black(next:$chan:served)] [string tolower $current_nick]] == -1} {
- set black(next:$chan:served) [linsert $black(next:$chan:served) end $current_nick]
- }
- } else {
- set black(next:$chan:served) $current_nick
- }
- }
- proc helpedpublic:cmd {nick host hand chan arg} {
- global black
- set user [lindex [split $arg] 0]
- set chan1 $chan
- foreach c [channels] {
- set backchan [channel get $c next-backchan]
- if {[string match -nocase $chan $backchan] && [channel get $c next]} {
- set chan "$c"
- }
- }
- helpedpublic:process $nick $host $hand $chan $chan1 $user
- }
- proc helpedpublic:process {nick host hand chan chan1 user} {
- global black
- set handle [nick2hand $user]
-
- if {![channel get $chan next]} {
- return
- }
- if {[isbotnick $user]} { return }
- if {[matchattr $handle $black(exceptflags) $chan]} {
- return
- }
- if {$user == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 next.12 none
- return
- }
- if {![onchan $user $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.usernotonchan $user
- return
- }
- if {[info exists black(next:$chan:list)]} {
- if {([lsearch -exact [string tolower $black(next:$chan:list)] [string tolower $user]] > -1)} {
- blacktools:tell $nick $host $hand $chan $chan1 next.13 $user
- return
- }
- }
- if {[info exists black(next:$chan:served)]} {
- if {[lsearch -exact [string tolower $black(next:$chan:served)] [string tolower $user]] > -1} {
- set entry_find 1
- set position [lsearch -exact [string tolower $black(next:$chan:served)] [string tolower $user]]
- set black(next:$chan:served) [lreplace $black(next:$chan:served) $position $position]
- }
- } else {
- blacktools:tell $nick $host $hand $chan $chan1 next.14 $user
- return
- }
- if {![info exists entry_find]} {
- blacktools:tell $nick $host $hand $chan $chan1 next.14 $user
- return
- }
- set backchan [channel get $chan next-backchan]
- set lang [channel get $chan lang]
- if {$lang == ""} { set lang [string tolower $black(default_lang)] }
- set replace(%current%) $user
- set replace(%nick%) $nick
- set replace(%hand%) $hand
- set replace(%chan%) $chan
- set message [string map [array get replace] $black(say.$lang.next.15)]
- if {($backchan != "") && [validchan $backchan]} {
- puthelp "PRIVMSG $backchan :$message"
- }
- if {[isvoice $user $chan]} {
- putserv "MODE $chan -v $user"
- }
- set message_1 [string map [array get replace] $black(say.$lang.next.4)]
- puthelp "NOTICE $user :$message_1"
- }
- proc noidlepublic:cmd {nick host hand chan arg} {
- global black
- set user [lindex [split $arg] 0]
- set chan1 $chan
- foreach c [channels] {
- set backchan [channel get $c next-backchan]
- if {[string match -nocase $chan $backchan] && [channel get $c next]} {
- set chan "$c"
- }
- }
- noidlepublic:process $nick $host $hand $chan $chan1 $user
- }
- proc noidlepublic:process {nick host hand chan chan1 user} {
- global black
- set handle [nick2hand $user]
- if {![channel get $chan next]} {
- return
- }
- if {[isbotnick $user]} { return }
- if {[matchattr $handle $black(exceptflags) $chan]} {
- return
- }
- if {$user == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 next.16 none
- return
- }
- if {![onchan $user $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.usernotonchan $user
- return
- }
- if {[info exists black(next:$chan:list)]} {
- if {([lsearch -exact [string tolower $black(next:$chan:list)] [string tolower $user]] > -1)} {
- blacktools:tell $nick $host $hand $chan $chan1 next.13 $user
- return
- }
- }
- if {([lsearch -exact [string tolower $black(next:$chan:served)] [string tolower $user]] > -1) || [info exists black(next:$chan:$nick:served)]} {
- blacktools:tell $nick $host $hand $chan $chan1 next.17 $user
- return
- }
- set backchan [channel get $chan next-backchan]
- set lang [channel get $chan lang]
- if {$lang == ""} { set lang [string tolower $black(default_lang)] }
- if {[channel get $chan next-noidlereason] == ""} {
- set replace(%chan%) $chan
- set message [string map [array get replace] $black(say.$lang.next.5)]
- set reason $message
- } else { set reason [channel get $chan next-noidlereason] }
- if {[channel get $chan next-bantime] == "0"} {
- set time $black(nextbantime)
- } else { set time [channel get $chan next-bantime] }
- set banmask *!*@[lindex [split [getchanhost $user $chan] "@"] 1]
- newchanban $chan $banmask "NOIDLE" $reason $time
- }
- proc skippublic:cmd {nick host hand chan arg} {
- global black
- set user [lindex [split $arg] 0]
- set chan1 $chan
- foreach c [channels] {
- set backchan [channel get $c next-backchan]
- if {[string match -nocase $chan $backchan] && [channel get $c next]} {
- set chan "$c"
- }
- }
- skippublic:process $nick $host $hand $chan $chan1 $user
- }
- proc skippublic:process {nick host hand chan chan1 user} {
- global black
- if {![channel get $chan next]} {
- return
- }
- if {$user == ""} {
- blacktools:tell $nick $host $hand $chan $chan1 next.18 none
- return
- }
- if {![onchan $user $chan]} {
- blacktools:tell $nick $host $hand $chan $chan1 gl.usernotonchan $user
- return
- }
- if {[info exists black(next:$chan:list)]} {
- if {[lsearch -exact [string tolower $black(next:$chan:list)] [string tolower $user]] > -1} {
- set position [lsearch -exact [string tolower $black(next:$chan:list)] [string tolower $user]]
- } else {
- blacktools:tell $nick $host $hand $chan $chan1 next.14 $user
- }
- } else {
- blacktools:tell $nick $host $hand $chan $chan1 next.10 none
- return
- }
- set black(next:$chan:list) [lreplace $black(next:$chan:list) $position $position]
- set black(next:$chan:list) [linsert $black(next:$chan:list) end $user]
- blacktools:tell $nick $host $hand $chan $chan1 next.19 $user
- }
- proc black:next:checklist {min hour day mon year} {
- global black
- if {([scan $min %d]+([scan $hour %d]*60)) % 5 == 0} {
- foreach chan [channels] {
- if {[channel get $chan next]} {
- black:next:joincheck $chan
- }
- }
- }
- }
- ############################## login check ##############################
- proc black:login:yes {nick host hand text {dest ""}} {
- global black
- if {$nick == "X"} {
- if {[info exists black(logged)]} { return }
- set black(logged) 1
- putlog "\[BlackTools\] Login succeded"
- }
- }
- proc black:login:no {nick host hand text {dest ""}} {
- global black
- if {$nick == "X"} {
- set black(notlogged) 1
- putlog "\[BlackTools\] Login unsuccesful"
- }
- }
- proc timer:login:check {min hour day mon year} {
- global black
- if {[info exists black(logged)]} { return }
- if {[info exists black(notlogged)]} { return }
- if {![info exists black(logged)] && ![info exists black(notlogged)] } {
- loginpublic my
- }
- }
- proc add:home:chan {chan} {
- global black
- addchan:stats $chan "HOMECHAN" "NONE"
- channel add $chan
- }
|