--[[ Mute 1.0 LUA 5.0/5.1/5.11 By Mutor 06/24/06 Переведел и пофиксил некоторые ошибки NRJ (08/17/06) Что же здесь вкусненького? -VIP/OP/Master доступ к командам -Можно глушить/снимать заглушку с ников онлайн и оффлайн -Нельзя заглушить/снять заглушку с самого себя -Менюшка -Можно смотреть список заглушенных ***Важное замечание (это если вы хотите, чтобы командами могли пользоваться дополнительные профили; переводите сами ): Allow certain profiles to use this script by enabling this profile permission: [x] Gag,Ungag Set permissions in the PtokaX GUI... Options -> Profile Manager. Do this for each profile that should be allowed these commands. Помощь по скрипту Команда Описание ???????????????????????????????????????? +mute глушим юзера +mhelp помощь +mlist просмотреть всех заглушенных +unmute вернуть возможность говорить в чате ???????????????????????????????????????? ]] MuteCfg = { -- Имя бота Bot = frmHub:GetHubBotName(), -- Бот оп или нет? BotIsOp = 1, -- Описание бота BotDesc = "Mute bot", -- Email бота BotMail = "mail@mail.ru", -- Название таблицы File = "MutedCfg.txt", -- Меню SubMenu = "Заглушки юзеров", -- Кому будут отправляться сообщения об ошибках? OpNick = "NRJ", -- Таблица заглушенных ников Muted = {}, } Main = function() gc = nil if _VERSION == "Lua 5.1" then gc = "collect" end if loadfile(MuteCfg.File) then dofile(MuteCfg.File) else Save_File(MuteCfg.File,MuteCfg,"MuteCfg") end if MuteCfg.Bot ~= frmHub:GetHubBotName() or MuteCfg.Bot == frmHub:GetHubBotName() and not frmHub:GetHubBot() then frmHub:RegBot(MuteCfg.Bot, MuteCfg.BotIsOp, MuteCfg.BotDesc, MuteCfg.BotMail) end OnError("Скрипт Mute 1.0 LUA версии ".._VERSION.." запущен. Используется памяти: "..gcinfo().." Кб.") end OnExit = function() OnError("Скрипт Mute 1.0 LUA версии ".._VERSION.." остановлен.") end OnError = function(msg) SendToNick(MuteCfg.OpNick,"<"..MuteCfg.Bot.."> "..msg) end function NewUserConnected(user, data) if GetUserProfile(user.sName) and GetProfilePermissions(user.iProfile).bGag then SendMuteCmds(user) user:SendData(MuteCfg.Bot,GetProfileName(user.iProfile).."'s команды заглушки пользователей доступны!".. "Команды доступны через всплывающее меню по правой кнопке мыши..") end end OpConnected = NewUserConnected ChatArrival = function(user, data) if MuteCfg.Muted[user.sName] then user:SendPM(MuteCfg.Bot,"Вам выставлена заглушка на чат! Вы не можете говорить ни в общем чате, ни в привате.") user:SendData(MuteCfg.Bot,"Вы заглушены! Бесполезно пытаться что-либо написать.") return 1 else if GetUserProfile(user.sName) and GetProfilePermissions(user.iProfile).bGag then local s,e,to = string.find(data,"^$To:%s(%S+)%sFrom:") local s,e,cmd = string.find( data, "%b<>%s%p(%w+)") if cmd and MuteCmds[cmd] then if to and to == MuteCfg.Bot then user:SendPM(MuteCfg.Bot,MuteCmds[cmd](user,data)) else user:SendData(MuteCfg.Bot,MuteCmds[cmd](user,data)) end collectgarbage(gc) return 1 end end end end ToArrival = ChatArrival MuteCmds = { mute = function(user,data) if user then local s,e,nick = string.find( data, "%b<>%s%p%w+%s(%S+)|$") if not nick then return "Ошибка!, Используйте: "..frmHub:GetPrefixes()[1].. "mute <ник>" else if nick == user.sName then return "Вы не можете заглушить самого себя "..user.sName..". Не будьте дураком!" end if MuteCfg.Muted[nick] then return "Пользователь: "..nick.." уже заглушен." else MuteCfg.Muted[nick] = 1 Save_File(MuteCfg.File,MuteCfg,"MuteCfg") local status = "оффлайн" if GetItemByName(nick) then status = "онлайн" SendToNick(nick,"<"..MuteCfg.Bot.."> Вы были заглушены. ".. "Теперь Вы не можете говорить ни в главном чате, ни в привате.") end SendToAll(MuteCfg.Bot,"Пользователь "..nick..", находящийся "..status..", заглушен ".. "и не может пользоваться ни чатом, ни приватом.") return nil end end else return "Заглушить юзера"," %[line:Ник]"," %[nick]" end end, unmute = function(user,data) if user then local s,e,nick = string.find( data, "%b<>%s%p%w+%s(%S+)|$") if not nick then return "Ошибка!, Используйте: "..frmHub:GetPrefixes()[1].. "unmute <ник>" else if nick == user.sName then return "Вы не можете снять заглушку с самого себя, "..user.sName..". Делать что ли нечего, да?" end if not MuteCfg.Muted[nick] then return "Пользователь: "..nick.." не был заглушен." else MuteCfg.Muted[nick] = nil Save_File(MuteCfg.File,MuteCfg,"MuteCfg") local status = "оффлайн" if GetItemByName(nick) then status = "онлайн" SendToNick(nick,"<"..MuteCfg.Bot.."> Заглущка на чат снята. ".. "Теперь вы можете говорить в чате и привате.") end SendToAll(MuteCfg.Bot," С пользователя "..nick..", находящегося "..status..", снята заглушка. ".. "Теперь он может общаться и в чате, и в привате.") return nil end end else return "Снять заглушку"," %[line:Ник]"," %[nick]" end end, mlist = function(user,data) if user then if next(MuteCfg.Muted) then local Count = 0 local reply = "Список заглушенных юзеров...\r\n\r\n\tНомер\t\tНик\r\n".. "\t"..string.rep("?",40).."\r\n" for i,v in pairs(MuteCfg.Muted) do Count = Count + 1 reply = reply.."\t"..string.format("[ %-3s ]",Count).."\t\t"..i.."\r\n" end return reply.."\n\t"..string.rep("?",40).."\r\n\r\n" else return "На данный момент никто не заглушен." end else return "Список заглушенных юзеров","","" end end, mhelp = function(user,data) if user then local reply = "Помощь по командам\r\n\r\n\tКоманда\t\tОписание\r\n".. "\t"..string.rep("?",40).."\r\n" for i,v in pairs(MuteCmds) do local desc,args = MuteCmds[i]() reply = reply.."\t+"..string.format("%-15s",i).."\t"..desc.."\r\n" end return reply.."\n\t"..string.rep("?",40).."\r\n\r\n" else return "Помощь","","" end end, } SendMuteCmds = function(user) for i,v in pairs(MuteCmds) do local desc,arg1,arg2 = MuteCmds[i]() user:SendData("$UserCommand 1 1 "..MuteCfg.SubMenu.."\\".. desc.."$<%[mynick]> +"..i..arg1.."|") user:SendData("$UserCommand 1 2 "..MuteCfg.SubMenu.."\\".. desc.."$$To: "..MuteCfg.Bot.." From: %[mynick] $<%[mynick]> +"..i..arg2.."|") collectgarbage(gc) end end Save_Serialize = function(tTable, sTableName, hFile, sTab) sTab = sTab or ""; hFile:write(sTab..sTableName.." = {\n" ) for key, value in pairs(tTable) do local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key) if(type(value) == "table") then Save_Serialize(value, sKey, hFile, sTab.."\t") else local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value) hFile:write( sTab.."\t"..sKey.." = "..sValue) end hFile:write( ",\n") end hFile:write( sTab.."}") end Save_File = function(file,table, tablename ) local hFile = io.open (file , "wb") Save_Serialize(table, tablename, hFile) hFile:close() collectgarbage(gc) end