diff --git a/botoffliner.lua b/botoffliner.lua index b6740a1..3a6170e 100644 --- a/botoffliner.lua +++ b/botoffliner.lua @@ -244,6 +244,8 @@ function ExecuteCommand( tUser, sCmd, sData ) local bFlag, Value = tOffliner.am( tUser, iID, sMagnet ) if not bFlag then Core.SendPmToUser( tUser, tConfig.sBotName, "Something went wrong. Contact hjpotter92" ) + elseif Value == -1 then + Core.SendPmToUser( tUser, tConfig.sBotName, "Magnet already exists in entry" ) else local sRoomReply, sPersonalReply = "Magnet %s added for entry #%d - %s", "The magnet has been added at ID #%d to entry #%d." sRoomReply = sRoomReply:format(sMagnet, iID, tRow.msg) @@ -309,46 +311,55 @@ function ExecuteCommand( tUser, sCmd, sData ) Core.SendPmToUser( tUser, tCfg.sBotName, "Sorry! You don't have access to this command." ) return true end - if not RegMan.GetReg( tBreak[1] ) then - Core.SendPmToUser( tUser, tCfg.sBotName, "Sorry! The user "..tBreak[1].." must register first." ) - return true - elseif tFunction.CheckModerator( tBreak[1] ) then - Core.SendPmToUser( tUser, tCfg.sBotName, "Sorry! The user "..tBreak[1].." is already a moderator." ) - return true - end - RegMan.ChangeReg( tBreak[1], RegMan.GetReg(tBreak[1]).sPassword, tCfg.iModProfile ) - if tOffliner.addmod( tUser, tBreak[1] ) then - sAllModerators, sAllCategories = tFunction.Connect() - local sChatMessage = "New moderator: "..tBreak[1].." ." - tFunction.SendToAll( tUser.sNick, sChatMessage ) - SendToRoom( tUser.sNick, sChatMessage, tCfg.sReportBot ) - return true - else - return true + local tMod={} + for iIndex, sNick in ipairs( tBreak ) do + + if not RegMan.GetReg( tBreak[iIndex] ) then + Core.SendPmToUser( tUser, tCfg.sBotName, "Sorry! The user "..tBreak[iIndex].." must register first." ) + return true + elseif tFunction.CheckModerator( tBreak[iIndex] ) then + Core.SendPmToUser( tUser, tCfg.sBotName, "Sorry! The user "..tBreak[iIndex].." is already a moderator." ) + return true + end + RegMan.ChangeReg( tBreak[iIndex], RegMan.GetReg(tBreak[iIndex]).sPassword, tCfg.iModProfile ) + if tOffliner.addmod( tUser, tBreak[iIndex] ) then + sAllModerators, sAllCategories = tFunction.Connect() + table.insert(tMod,tBreak[iIndex]) + return true + else + return true + end end + local sChatMessage = "New moderator(s): "..print(table.concat(tMod, ", ")).." ." + tFunction.SendToAll( tUser.sNick, sChatMessage ) + SendToRoom( tUser.sNick, sChatMessage, tCfg.sReportBot ) elseif sCmd == "delmod" then if not tProfiles.AllowVIP[tUser.iProfile] then Core.SendPmToUser( tUser, tCfg.sBotName, "Sorry! You don't have access to this command." ) return true end - if not tFunction.CheckModerator( tBreak[1] ) then - Core.SendPmToUser( tUser, tCfg.sBotName, "Sorry! The user "..tBreak[1].." is not a moderator." ) - return true + local tMod={} + for iIndex,sNick in ipairs( tBreak ) do + + if not RegMan.GetReg( tBreak[iIndex] ) then + Core.SendPmToUser( tUser, tCfg.sBotName, "Sorry! The user "..tBreak[iIndex].." is unregistered at the moment." ) + return true + elseif not tProfiles.AllowAdmin[tUser.iProfile] then + RegMan.ChangeReg( tBreak[iIndex], RegMan.GetReg(tBreak[iIndex]).sPassword, tCfg.iRegProfile ) + return true + end + + tOffliner.delmod( tUser, tBreak[iIndex] ) + sAllModerators, sAllCategories = tFunction.Connect() + table.insert(tMod,tBreak[iIndex]) + end - tOffliner.delmod( tUser, tBreak[1] ) - sAllModerators, sAllCategories = tFunction.Connect() - local sChatMessage = "Moderator removed: "..tBreak[1].." ." - tFunction.SendToAll( tUser.sNick, sChatMessage ) SendToRoom( tUser.sNick, sChatMessage, tCfg.sReportBot ) - if not RegMan.GetReg( tBreak[1] ) then - Core.SendPmToUser( tUser, tCfg.sBotName, "Sorry! The user "..tBreak[1].." is unregistered at the moment." ) - return true - elseif not tProfiles.AllowAdmin[tUser.iProfile] then - RegMan.ChangeReg( tBreak[1], RegMan.GetReg(tBreak[1]).sPassword, tCfg.iRegProfile ) - return true - end - return true + tFunction.SendToAll( tUser.sNick, sChatMessage ) + local sChatMessage = "Moderator(s) removed: "..print(table.concat(tMod, ", ")).." ." + + elseif sCmd == "addctg" then if not tProfiles.AllowAdmin[tUser.iProfile] then @@ -356,6 +367,8 @@ function ExecuteCommand( tUser, sCmd, sData ) return true end tOffliner.addctg( tUser, tBreak[1] ) + tFunction.SendToAll( tUser.sNick, sChatMessage ) + local sChatMessage="New category added : "..tBreak[1].." ." return true elseif sCmd == "delctg" then @@ -363,6 +376,9 @@ function ExecuteCommand( tUser, sCmd, sData ) Core.SendPmToUser( tUser, tCfg.sBotName, "Sorry! You don't have access to this command." ) return true end + tOffliner.delctg( tUser, tBreak[1] ) + tFunction.SendToAll( tUser.sNick, sChatMessage ) + local sChatMessage="Category removed : "..tBreak[1].." ." return true else