Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add/remove multiple mods at a time , modified addCtg delCtg commands #23

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 47 additions & 31 deletions botoffliner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -309,60 +311,74 @@ 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
Core.SendPmToUser( tUser, tCfg.sBotName, "Sorry! You don't have access to this command." )
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
if not tProfiles.AllowAdmin[tUser.iProfile] then
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
Expand Down