PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: Zigurds on 04 March, 2005, 09:19:11

Title: Need Censorbot and slots vs connection bot
Post by: Zigurds on 04 March, 2005, 09:19:11
------------------------------------------------------------------------
-- CENSORBOTS (verlihub version)
------------------------------------------------------------------------

trigs = {["?"]=1,["?"]=2,["?"]=3,["?"]=4,["?"]=5,["?"]=6,["?"]=7,["?"]=8,["?"]=9,["?"]=10,["?"]=11,["?"]=12,["?"]=13,["?"]=14,["?"]=15,["?"]=16,["?"]=17,["?"]=18,["?"]=19,["?"]=20,["?"]=21,["?"]=22,["?"]=23,["?"]=24,["?"]=25,["?"]=26,["?"]=27,["?"]=28,["?"]=29,["?"]=30}
max_class = 3
botname = "-CENSORBOTS-"
iemesls = "6. rule - Only Latvian language"

--------
 
function IsUserAdmin(nick)
res, class = VH:GetUserClass(nick)
if res and class >= max_class then
return true
else
return false
end
end

function cenzura(nick,data)
if not IsUserAdmin(nick) then
for key,a in trigs do
if(string.find(data, key)) then
VH:SendDataToUser("<"..botname.."> "..iemesls,nick)
VH:CloseConnection(nick);
return 0
end
end
end
return 1
end

function VH_OnParsedMsgChat(nick, data)
return cenzura(nick,data)
end

function VH_OnParsedMsgMyINFO(nick, data)
return cenzura(nick,data)
end


---------------------------------------

-- Slots vs Connection Speed by   [aXs] Wellx   11/06-03
-- Thx goes to Sedulus & aMutex for idea's and help
-- This script checks for slots vs speed and Disconnect if not Master/Operator/VIP
-- Optimized a bit made some no-used code at first...p

Connection={}
Connection["28.8Kbps"] = 0   
Connection["33.6Kbps"] = 0
Connection["56Kbps"] = 0
Connection["ISDN"] = 0
Connection["Satellite"] = 0
Connection["Cable"] = 20
Connection["DSL"] = 24
Connection["LAN(T1)"] = 27
Connection["LAN(T3)"] = 30

function DataArrival(curUser, data)
   if strsub( data, 1, 8 ) == "$MyINFO " and (curUser.iProfile < 0 or curUser.iProfile > 2) then
   SlotsCheck(curUser, strsub(data, 1, strlen(data) -1))
   end
end

function SlotsCheck(curUser, myinfo)   
local s,e,Slots,speed = strfind(myinfo, "S:([^,>]+).*>$ $([^$]*)")  
local Slots = tonumber(Slots)  
   if speed then
   local speed = strsub(speed,1,strlen(speed)-1)
      if Connection[speed] and Slots > Connection[speed] then
      curUser:SendPM("<-SLOTBOTS->", "Par daudz atveertu slotu shim piesleegumam! Maksimums ir ("..Connection[speed]..") Tev atveerti ("..Slots..") sloti")
--      SendToOps("<-SLOTBOTS->","*** Juuzeris <"..curUser.sName.."> IP <" ..curUser.sIP.."> Nepareizs slotu skaits! Atvienots:)")
      curUser:Disconnect()
      end
   end
end

----------------------------------------------------
owner for Latvian hub Alfa