Hello
I'm doing a script "all in one" and i need help with one thing.
I need a part for this script that can manage the enabled and disabled commands for each profile.
For example:
Command !MyInfo :
Master = 1
Operator = 1
Vip = 1
Reg = 0
User = 0
o = disabled
1 = enabled
Please help me with this part. I will put this part in the script i am doing and when it's finished, i will put the script here. It's a real good "all in one" script. Very simple and not heavy (200KB in ptokax)
Thnks in advance,
Props
just use a table like so...
tCommandLevels.Command[sCommand][sProfile] = 1\0
so in ur example it would be
Command !MyInfo :
tCommandLevels.Command["MyInfo"]["Master"] = 1
tCommandLevels.Command["MyInfo"]["Operator"] = 1
tCommandLevels.Command["MyInfo"]["Vip"] = 1
tCommandLevels.Command["MyInfo"]["Reg"] = 0
tCommandLevels.Command["MyInfo"]["User"] = 0
or in cSlave u can simply :O
function fFunction(User, sData, bInPm)
-- Code here for command
end
cSlave.Commands.Register(sCommand, fFunction, iMinimumLevel, sUsage, sInformation)
Hello Corayzon
Command !MyInfo :
tCommandLevels.Command["MyInfo"]["Master"] = 1
tCommandLevels.Command["MyInfo"]["Operator"] = 1
tCommandLevels.Command["MyInfo"]["Vip"] = 1
tCommandLevels.Command["MyInfo"]["Reg"] = 0
tCommandLevels.Command["MyInfo"]["User"] = 0
So, how does the script knows that ...
tCommandLevels.Command["MyInfo"]["Reg"] = 0
...is for the profile number 3, for example?
i am really confused about this part.
What i want to do, is a part of the great robocop script, where you can manage what commands are enabled to each profile. Then i want to do this:
Command !userinfo
Operators can do !userinfo on "REG" "VIP" and "USER"
Operator can't do !userinfo on "OP" and "MASTER"
Command !kick
Operators can do !user info on "REG" and "USER"
Operator can't do !kick on "VIP" "OP" and "MASTER"
Do you know how to do that? can you explain with an exemple of 1 or 2 commands? Thnks
it isnt that hard, all hes saying is that u should use a table to store each command, and what profile can acess it
"myinfo" <-- thats the command
"Master" <-- thats the profile
"1" <-- that means users with that profile can use the command
"0" <-- means the inverse of above
yeps ;)
tAllow = {
[0] = 1, --// Master
[1] = 1, --// Operator
[2] = 1, --// Vip
[3] = 1, --// REG
[-1] = 0, --// non-Reg Users
}
if tAllow[CurUser.iProfile] == 1 then
[COLOR=green]--// Do Your Crap Here[/COLOR]
end
Look Forward to seeing your script :) :)
Thnks people... sorry but i am not understanding :S
Please specify a little bit more. I've already ask for optimus help in PM (Optimus, please see your PM), and i ask for help of others too.
Well, maybe i'm not explayning myself very well.
So, What i want is:
I want my script to do some funcions of robocop, like manage enabled and disabled commands to each profile, managed who can ban who (kick, warn, ban...) and who can PM who.
Thanks and specify a little bit more what i have do add to this script, please.
Props
this should also work I think (just a thought):
tAllow = {
[0] = 5, --// Master
[1] = 4, --// Operator
[2] = 3, --// Vip
[3] = 2, --// REG
[-1] = 1, --// non-Reg Users
}
function ChatArrival
if cmd == "#rules" and tAllow[CurUser.iProfile] >= 1 then
function showrules
return 1
elseif cmd == "#ban" and tAllow[CurUser.iProfile] >= 4 then
function ban
return 1
end
end
I could be wrong, but I think it should be right...
Good luck
yes it can work, but its more efficient to parse all the commands in a table, as it was done in zrightclicker .
Thnks Dessamator
Really good idea you gave me ;)
Props
Hello Again people.
I have another help request.
In the user info part of the script, i will like to so a change, but i don't know how.
When i enter the hub, it shows this :
[18:56:15] <[BOT]Zeus> Hello your share is 400.26899126824 GB.
i would like to change this part (400.26899126824 GB) to this:
400.27 GB
Is the any way to do it?
Thnks
Hi...
this is simple :-)
I will give you an example... from the bot I build now...
ChatArrival:
elseif (string.lower(cmd) == (prefix.."share")) then
SendToUser(curUser, "Your current sharesize is: "..string.format( "%.2f",curUser.iShareSize / gb).." Gb.")
return 1
where gb is: gb = 1024*1024*1024
This is the interesting part for you: string.format( "%.2f",curUser.iShareSize / gb)
The "%.2f" will do the job!
Good luck!
Very simple :)
Thanks TTB
props
np... :D
You're welcome
hello.
i have another question. I want to notify only a single profile (in this case, profile master, profile number 0) when somebody enters the hub. Is that possible?
Thanks
Props
Here u have:
-- Hello bot by TTB
-- wrote in 1 minute
bot = "Hello"
function Main()
frmHub:RegBot(bot)
end
function OpConnected(user,data)
if user.iProfile == 0 then
SendToAll(bot, "Hello Master "..user.sName..". Have a nice trip...")
return 1
end
end
Hello TTB
It's not like that. This is very simple. LOL
What i want is:
I want the script to send a PM to the founder of the hub, each time an user enters the hub. The message is only to the founder, and not to all OPs. The founder have the profile number 0.
Thnks
-- Hello bot by TTB
-- wrote in 1 minute
-- Edited by GeceBekcisi to satisfy -PT-B2S's needs
sBot = "Hello"
sOwner = "Write here your nick"
function Main()
frmHub:RegBot(sBot)
end
function NewUserConnected(curUser,data)
SendPmToNick(sOwner, sBot, ""..curUser.sName.." entered hub.")
return 1
end
yeah :D
this is the way i have it already.
But this only sends the message to a specified nick. I really want it to send to a profile number, instead of nick :)
Thnks
tis simple, do an if statement, in the newuserconnnected
hint : if user.iProfile == ? then ...
QuoteOriginally posted by Dessamator
tis simple, do an if statement, in the newuserconnnected
hint : if user.iProfile == ? then ...
No you need to get online user from specific profile and send...
Table is required...
this should be helpfull not tested... done in 2 min
---------------------------------------------------------------------------------------------------
--## Annouce Users To Profile - Bot by: NightLitch
---------------------------------------------------------------------------------------------------
botName = "Reporter" -- Set Botname
sendMsgIn = "PM" -- Set ( MAIN ) or ( PM )
sendToProfile = "Master" -- Set ProfileName to send Msg to
sendMessage = " entered the hub" -- Set Msg to send ( ) is replaced with users Nickname
---------------------------------------------------------------------------------------------------
function Main()
frmHub:RegBot(botName)
end
---------------------------------------------------------------------------------------------------
function NewUserConnected(sUser)
local op =GetOnlineOperators() --- Return table with all logged user objects with operator status.
for i = 1,table.getn(op) do
if GetProfileName(op[i].iProfile) == sendToProfile then
if sendMsgIn == "PM" then
op[i].SendPM(botName, string.gsub(sendMessage, "", sUser.sName) )
elseif sendMsgIn == "MAIN" then
op[i].SendData(botName, string.gsub(sendMessage, "", sUser.sName) )
end
end
end
end
---------------------------------------------------------------------------------------------------
--// NightLitch 2005-07-16
cheers
hmm, yap looks better,
i misread the request :)
Thanks very much Dessamator and NightLitch
i have made it another way:
--PM TO A DEFINED PROFILE WHEN USER ENTER THE HUB--
--By -PT-B2S
--20-07-2005
---------------------------------------------------------------------------------------------------
iPmToProfile = "name of the profile who will receive the PM)
sBot = "name of the bot"
function NewUserConnected(oUser)
pmto = GetUsersByProfile(iPmToProfile)
pmto:SendData(sbot, "new enter : "..oUser.sName.." . ")
end
Thnks and props
Now i have another question.
I need a command to the script that the script will know if the user is online.
Something like this:
if oUser is online then
I know this is not the right way to do it, so...
function NewUserSeeing this(oUser)
if (oUser knows how to do this) then
SendTo-PT-B2S(oUser, "I know how to do it. It's this way: ......... ")
end
end
ehehehe
Just kidding, but if you know it, tell me please.
Thnks and props
local Nick = GetItemByName(UserName)
if Nick then
User is online
sorry ??????Hawk?????? but this doesn't work.
If i say in the hub:
!warn test reason
and the user "test" is not online, the script gives me an error.
See it :
function ChatArrival(oUser, data)
if (string.sub(data,1,1) == "<" or string.sub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
data = string.sub(data,1,string.len(data)-1)
local s,e, cmd, extra, rest = string.find(data, "%b<>%s+(%S+)%s*(%S*)%s*(.*)")
if (string.sub(cmd,1,1) == "!") then
if (cmd == "!warn") then
local Nick = GetItemByName(extra)
if Nick then
Nick:TempBan()
This kind of thing doesn't work
i need a command that verifies if the user mentioned in "extra" is really online.
Props
Hello. I need one more thing to the script, please.
In some hubs, you have to share xGB to enter the hub if you are regged. For exemple, if you have 1GB you can enter if you are non regged but if you are regged, you have to share 5GB. So, what i want is a line to the script that does this:
If the user is vip (profile 3, for exemple) but have less than the minimum share for vips (causa he have to format the hard disk or something) the script will unreg the user so the user can enter.
Thnks and props.
Hi, the code you posted... it is not very good.
if (string.sub(data,1,1) == "<" or string.sub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
The way you do this is wrong. In LUA5 ChatArrival is for main chat, and ToArrival is for PM. IN this case, the whole line is not needed (in LUA4 it is...).
I should do it a different way...
function ChatArrival(curUser,data)
data = string.sub(data,1,string.len(data)-1)
local s,e,cmd,extra,rest = string.find(data, "%b<>%s+(%S+)%s+(%S+)%s+(.*)")
if (string.sub(cmd,1,1) == "!") then
if (cmd == "!warn") then
if GetItemByName(extra) then
extra:TempBan()
-- ## REST OF YOUR CODE ## --
end
end
end
end
end
It is just a thought... I wrote it very fast, but try something like this...
Thaks TTB. I will try this.
Props ;)
Hello Again
I need a thing to my script. I want to block the "dc++ kick command". Some clients (like strongdc++, dcdm and other OP clients) have a own kick command. I want to block this command, and if a user uses this command, the script will do his own !kick command instead of the command from the client.
Thnks again. Props
Simple, use pattern matching to find the raw command and return 1 .
hello.
that's not so simple. I'm using this:
function ChatArrival(oUser, data)
data = string.sub(data,1,string.len(data)-1)
local s,e, cmd, extra, rest = string.find(data, "%b<>%s+(%S+)%s*(%S*)%s*(.*)")
if (cmd == "$kick") then
return 1
end
end
end
IT's not working.
Props
Quote[18:46:37] Syntax error there was someone on the board, who asked if it is possible to block te inbuild kick command... Is this possible?
[18:47:23] ? yeah... a return 1 in the KickArrival block the actual kick...
[18:48:17] ? and then you need to catch the You are being kicked because string in ToArrival and return 1 on that...
[18:49:59] ? and to stop the msg from appering in the status bar... do a string.find on is kicking in the ChatArrival
That should give you an idea... ;)
Thanx to madman for the tip, here we go:
-- Kick interception by TTB
-- 01-08-2005
-- Requested by -PT-B2S
-- Thanx to madman for the tip ;-)
------------------------------------------------------------------------
bot = "kickintercept"
function ChatArrival(curUser,data)
data = string.sub(data,1,string.len(data)-1)
s,e,all = string.find(data,"%b<>%s+(.*)")
if string.find(all,"is kicking") then
SendToAll(bot,"Kick command not enabled!")
return 1
end
end
function KickArrival(curUser, data)
if string.find(data,"$Kick") then
return 1
end
end
function ToArrival(curUser,data)
local _,_,whoTo,mes = string.find(data,"$To:%s+(%S+)%s+From:%s+%S+%s+$(.*)")
if (string.find(mes,"%b<>%s+(.*)")) then
data = string.sub(mes,1,string.len(mes)-1)
if string.find(data,"You are being kicked because") then
return 1
end
end
end
pure code, no extra shit:
function ToArrival(curUser, data)
if string.find(data, "You are being kicked because") then
return 1
end
end
function ChatArrival(curUser, data)
if string.find(data, "is kicking") then
return 1
end
end
function KickArrival(curUser, data)
return 1
end
Also thanx to madman!
Ok this is working, the script bloks the command.
thnks to both of you
This is what i want now:
I want the script to do the "!kick " command when an OP try to use the client $kick command.
Props
post above updated!
my last post edited :) thnks
Maybe you can try that on your own... You know how to catch values with a string, likelocal s,e,cmd,extra,rest = string.find(data, "%b<>%s+(%S+)%s+(%S+)%s+(.*)")
experiment with this kind of things...! So, the tip is: Catch the kick with a string, and make "$Kick victim reason" to "!kick victim reason". Notice that the !kick shouldn't be returned (use return 0). G00d luck
was just thinking, maybe this can't be done. Scripts doesn't catch other commands from scripts... Maybe someone else knows... ?(
TTB
Maybe you can help me.
Think with me:
function ToArrival(curUser,data)
local _,_,whoTo,mes = string.find(data,"$To:%s+(%S+)%s+From:%s+%S+%s+$(.*)")
if (string.find(mes,"%b<>%s+(.*)")) then
data = string.sub(mes,1,string.len(mes)-1)
if string.find(data,"You are being kicked because") then
return 1
end
end
end
If this thing can detect this:
("You are being kicked because")
There must be a way to detect the reason.
When i have the reason identified, i'll have the victim user (the one that will be kicked) and the reason.
Since the !kick command is in the same script (this is an 'all in one' script) there must be a way to send the command (!kick user reason) instead of the client command ($kick user)
can you help me?
Thnks,
props
To catch the Reason...
_,_,Reason = string.find(data, "You are being kicked because: (.*)|")
As for the Kick... I dont kno...And to tierd to try
Ok, thnks madman.
now the kick.
Well, this thing does't work, as everybody knows:
SendToAll(user, "!kick user reason")
So, does somebody knows how to do it? thnks
This was damn irritating to build... but it should work now, tested it, so please try this:
-- Kick interception by TTB v.2
-- 02-08-2005
-- Requested by -PT-B2S
-- Thanx to madman for the tip ;-)
----------------------------------------------------------------------------------------
bot = "kickintercept"
function ChatArrival(curUser,data)
if string.find(data,"is kicking") then
return 1
end
end
function KickArrival(curUser, data)
if string.find(data,"$Kick") then
return 1
end
end
function ToArrival(curUser,data)
local _,_,whoTo,mes = string.find(data,"$To:%s+(%S+)%s+From:%s+%S+%s+$(.*)")
if (string.find(mes,"%b<>%s+(.*)")) then
victim = whoTo
data = string.sub(mes,1,string.len(mes)-1)
if string.find(data,"You are being kicked because") then
data = string.gsub(data,"(%S+)%s+You are being kicked because: ","")
SendToAll(bot,"!kick "..victim.." "..data)
return 1
end
end
end
Hello TTB
This line doesn't work, as i said:
SendToAll(bot,"!kick "..victim.." "..data)
This line sends this text to the hub:
!kick 'user' 'reason'
But the ptokax don't recognize it like a command. the text is seen by everyone, but it is not considered a command.
Thnks again
Props
The Problem is now solved!!!
Since you gave me an help with this, i will post the way i solved it here!
By the way, my profile numbers are:
REG = 0
ELITE = 1
VIP = 2
OP = 3
MODERATOR = 4
FOUNDER = 5
--## Kick interception by Hahn?(-PT-B2S)
-- 02-08-2005
-- Thanx to madman, TTB and zero-cool for the help
sBot = "name of the bot"
iTimeBan = 30, -- Time fot Timeban in minutes
kickLimit = 3, -- kick limit
warnLimit = 3, -- warn limit
kwTab = {
tKick = {},
tWarn = {},
}
function ChatArrival(oUser,data)
if string.find(data,"is kicking") then
return 1
end
end
function KickArrival(oUser, data)
if string.find(data,"$Kick") then
return 1
end
end
function ToArrival(oUser,data)
local _,_,whoTo,mes = string.find(data,"$To:%s+(%S+)%s+From:%s+%S+%s+$(.*)")
if (string.find(mes,"%b<>%s+(.*)")) then
victim = whoTo
data = string.sub(mes,1,string.len(mes)-1)
if string.find(data,"You are being kicked because") then
reason = string.gsub(data,"(%S+)%s+You are being kicked because: ","")
iVictim = GetItemByName(whoTo)
SendToOps(sBot, " The User " ..oUser.sName.. " used this commad: -- kick -- on the user -- "..victim.." --")
if oUser.bOperator then
if (victim == nil) then
oUser:SendData(sBot, "***Error, The user "..victim.." is not online")
else
if (oUser.bOperator) and (iVictim.iProfile < oUser.iProfile) then
if kwTab.tKick[victim] == nil then
kwTab.tKick[victim] = {}
kwTab.tKick[victim]["Kicked"] = {}
kwTab.tKick[victim]["Kicked"] = 1
else
kwTab.tKick[victim]["Kicked"] = kwTab.tKick[victim]["Kicked"] + 1
end
if (kwTab.tKick[victim]["Kicked"] == kickLimit) then
iVictim:SendPM(sBot, "You are beeing banned cause you have reached the kick limit with the reason: "..reason)
SendToOps(sBot, "The User "..victim.." was banned by "..oUser.sName.." ,after reach the kick limit with the reason: "..reason)
kwTab.tKick[victim] = nil
iVictim:TimeBan(iTimeBan)
else
iVictim:SendPM(sBot, "You are being kicked by "..oUser.sName.." because: "..reason)
SendToOps(sBot, "O User "..victim.." was kicked by "..oUser.sName.." because: "..reason)
iVictim:TempBan()
iVictim:Disconnect()
end
end
if (oUser.bOperator) and (iVictim.iProfile > oUser.iProfile) then
oUser:SendData(sBot, "You can not kick "..victim.." because he has a superior profile than yours!")
end
end
else
oUser:SendData(sBot, "*** Error, You can not use this command.")
end
return 1
end
end
end
The !kick command is like this one i have posted here and uses this too:
tConf = {
mSet = {
iTimeBan = 30, -- in minutes
kLimit = 3, -- kick limit
wLimit = 3, -- warn limit
},
tKick = {},
tWarn = {},
}
Tested and working perfectelly
Thanks Again and Props
Of course... that is the best way, but it isn't catched by another script...
But indeed, what you did, if you put it in the script it should catch, then it works. Well... we just learn from this, and it is nice that you got now what you need. :D
Greetz.
Yes TTB, it's true, but as i said, this is an "all in one" script that i am doing, and it has all the commands, including the !kick command. :D
Props
Ghehe, I could have known. Well, the way to catch it was a little bit frustrating, but these are the things were we can learn from. Ghehe, g00d luck with the all in 1 script. You know where to post when you have probs :)
Hello again people.
Well, now i want to do a difficult thing (i think :P )
I want a script that automatically erase the registered users that don't enter the hub for more than 1 month. I'm not very good with "timers" in LUA scripts, so i ask for your help.
Is that possible? i Hope so.
Thnks and props
have a look at plop's reg cleaner, it does that !
Thnks dessamator ;)
Props
hmm , no probs, btw, that part of that code u used in that script was from jiten's kick warn bot, if ur gonna use his code, leave the credits there !
No Dessamator... In he script that i am doing, the kick and warn part, first was inspired in that jiten's script you're talking about. But this one now is my own made! I made it myself, with no need to look at jiten's script. Maybe it seems iqual, but it's not! Anyway, thnks :)
Props
Well, need another help
I want a simple script that identifies the ISP of the user, and sends a message like this on login:
Hello user dhdhdf. Your ISP is : " "
ISP is the internet server of the user.
------------------------------
Another thing.
I need a script that only allows multisource downloading if the user share more than xGB.
Thnks and Props
QuoteOriginally posted by -PT-B2S
Well, need another help
I want a simple script that identifies the ISP of the user, and sends a message like this on login:
Hello user dhdhdf. Your ISP is : " "
ISP is the internet server of the user.
First of all, welcome here, nice to see so dedicated new volunteers.
Second: the ISP can only be determined if you have a table of proper ISPs which you can match the IP address against. I don't know what format DCDM++ uses (most likely XML), but I will make a parser script for that and as such, an ISP detector.
QuoteOriginally posted by -PT-B2S
I need a script that only allows multisource downloading if the user share more than xGB.
This cannot be done, as multisource downloading clients cannot be detected by the hub software itself. Moreover, the hub server has nothing to do with file transfers (you can only control the handshakes through it), thats why the protocol is called DirectConnect.
Thanks bastya_elvtars
The script to detect the ISP i have already done and its workin :)
The other, i think its possible to detect the multisource client, if the user isn't emulating the TAG. (unless its revconnect, wich has the same tag as DC++) Bur if you can block download from some users with a script, you will be able to block downloads in this case too. I don't know if there is possible to detect if an user is using multisource clients, but you can block downloads, so, its not really "direct connect", the info has to pass by the server :)
Props and thnks for the help