-
Notifications
You must be signed in to change notification settings - Fork 15
API Lua Events
This is called when the script is loaded. For example:
function Main()
VH:SendToOpChat('Hey a new LUA script has just been loaded');
return 1;
end
or to register a new BOT in the user's list:
function Main()
VH:AddRobot('Crazy BOT', 10, 'I am a BOT', "Bot", 'nospam@hub.com', "0")
end
The method returns current script name as first argument
This is called before the script is unloaded. For example:
function Unload()
VH:SendToOpChat('Hey a LUA script has just been unloaded');
return 1;
end
or to remove a BOT previously added with VH:AddRobot
:
function UnLoad()
VH:DelRobot('Crazy BOT')
end
Called every seconds as the time specified in the timer_serv_period
variable. For example to print the date in OPChat:
time = os.time ()
function VH_OnTimer()
if(os.difftime (os.time (), time+10) <= 10) then
VH:SendToOpChat('Harry up!');
end
return 1;
end
It will print the given string in OP Chat twenty times.
VH_OnScriptCommand(command,data,plugin,script)
(command,data) function for script communication
Note that in LUA functions you must put return 1 on the end of the function otherwise the hub will discard the action.
The input parameters are always strings and they never contains end-pipe
You can also use _PLUGINVERSION or _HUBVERSION global variable which will give the plugin and VerliHub version respectively
This method is called when a new user is registered. It returns the op
who made the registration, the registered nick
with given class
. For example:
function VH_OnNewReg (nick, class, op)
if nick == 'Mario' then
VH:SendToOpChat('Mario has just registered "' .. nick ..'" with class ' .. class);
end
return 1;
end
Input parameters: 1= nick, 2= class, 3= op
This method is called when a OP delete a user. It returns the op
who made the action, the deleted nick
with given class
. For example:
function VH_OnDelReg (nick, class, op)
if nick == 'Mario' and class == 5 then
VH:SendToOpChat('Ask Mario why he just deleted "' .. nick ..'" with class ' .. class);
end
return 1;
end
Input parameters: 1= nick, 2= class, 3= op
This method is called when user' class is changed. It returns the op
who made the action, the nick
with old_class
and new_class
. For example:
function VH_OnUpdateClass (op, nick, old_class, new_class)
if nick == 'Mario' and (old_class < new_class) then
VH:SendToOpChat('Mario has just promoted "' .. nick ..'" to class ' .. class);
end
return 1;
end
Input parameters: 1= nick, 2= old_class, 3= new_class, 4= op
This method is called when there is a new incoming connection.. It returns the user's ip
. For example:
function VH_OnNewConn (ip)
if ip == '127.0.0.1' then
VH:SendToOpChat('A new connection has just started with local IP: ' .. ip);
end
return 1;
end
Input parameters: 1= ip
This method is called when a new user with nick
starts to log out. It returns the user's ip
. For example:
function VH_OnCloseConn (ip, nick)
if ip == '127.0.0.1' then
VH:SendToOpChat('A new user has just started to log out with a local IP: ' .. ip .. ' and nick: "' .. nick ..'"');
end
return 1;
end
This event cannot be discarded.
Input parameters: 1= ip, 2= nick
This method is called when the user ends the login protocol and he get the MOTD. It returns the nick
and his IP
. For example:
function VH_OnUserLogin (nick, ip)
VH:SendToOpChat('LOGGER: ' .. nick ..' has just entered in the hub');
return 1;
end
This event cannot be discarded.
Input parameters: 1= nick, 2= ip
This method is called when a user logout with nick
and ip
is completed. This event cannot be discarded.
Input parameters: 1= nick, 2= ip
Note that in LUA functions you must put return 1 on the end of the function otherwise the hub will discard the action.
The input parameters are always strings and they never contains end-pipe
You can also use _PLUGINVERSION or _HUBVERSION global variable which will give the plugin and VerliHub version respectively
This method is called when a new user is registered. It returns the op
who made the registration, the registered nick
with given class
. For example:
function VH_OnNewReg (nick, class, op)
if nick == 'Mario' then
VH:SendToOpChat('Mario has just registered "' .. nick ..'" with class ' .. class);
end
return 1;
end
Input parameters: 1= nick, 2= class, 3= op
This method is called when a OP delete a user. It returns the op
who made the action, the deleted nick
with given class
. For example:
function VH_OnDelReg (nick, class, op)
if nick == 'Mario' and class == 5 then
VH:SendToOpChat('Ask Mario why he just deleted "' .. nick ..'" with class ' .. class);
end
return 1;
end
Input parameters: 1= nick, 2= class, 3= op
This method is called when user' class is changed. It returns the op
who made the action, the nick
with old_class
and new_class
. For example:
function VH_OnUpdateClass (op, nick, old_class, new_class)
if nick == 'Mario' and (old_class < new_class) then
VH:SendToOpChat('Mario has just promoted "' .. nick ..'" to class ' .. class);
end
return 1;
end
Input parameters: 1= nick, 2= old_class, 3= new_class, 4= op
This method is called when there is a new incoming connection.. It returns the user's ip
. For example:
function VH_OnNewConn (ip)
if ip == '127.0.0.1' then
VH:SendToOpChat('A new connection has just started with local IP: ' .. ip);
end
return 1;
end
Input parameters: 1= ip
This method is called when a new user with nick
starts to log out. It returns the user's ip
. For example:
function VH_OnCloseConn (ip, nick)
if ip == '127.0.0.1' then
VH:SendToOpChat('A new user has just started to log out with a local IP: ' .. ip .. ' and nick: "' .. nick ..'"');
end
return 1;
end
This event cannot be discarded.
Input parameters: 1= ip, 2= nick
This method is called when the user ends the login protocol and he get the MOTD. It returns the nick
and his IP
. For example:
function VH_OnUserLogin (nick, ip)
VH:SendToOpChat('LOGGER: ' .. nick ..' has just entered in the hub');
return 1;
end
This event cannot be discarded.
Input parameters: 1= nick, 2= ip
This method is called when a user logout with nick
and ip
is completed. This event cannot be discarded.
Input parameters: 1= nick, 2= ip
Note that in LUA functions you must put return 1 on the end of the function otherwise the hub will discard the action.
The input parameters are always strings and they never contains end-pipe
You can also use _PLUGINVERSION or _HUBVERSION global variable which will give the plugin and VerliHub version respectively
This method is called when an operator makes a new kick. It returns the op who executed the command, the kicked user'snick
and the kick reason
. Return false to ignore the kick, otherwise return true. For example:
function VH_OnOperatorKicks (op, nick, reason)
VH:SendToOpChat('LOGGER: ' .. op .. ' has just kicked "' .. nick ..'" with reason: "' .. class .. '"');
return 1;
end
Input parameters: 1= op, 2= nick, 3= reason
This method is called when an operator drops a user using the !drop command. It returns the op
who executed the command and user's nick
. Return false to ignore the drop, otherwise return true. For example:
function VH_OnOperatorDrops (op, nick)
VH:SendToOpChat('LOGGER: ' .. op .. ' has just dropped "' .. nick .. '"');
return 1;
end
Input parameters: 1= op, 2= nick
This method is called when an operator bans a user. It returns the op
who executed the command, the user's nick
and ip
and the ban reason
. For example:
function VH_OnNewBan (op, ip, nick, reason)
VH:SendToOpChat('LOGGER: ' .. op .. ' has just banned "' .. nick ..'" (IP: ' .. ip .. ')with reason: "' .. reason ..'"');
return 1;
end
Return false to ignore the ban, otherwise return true.
Input parameters: 1= op, **2=**ip, 3= nick, 4= reason
This method is called when an operator unbans a user. It returns the op
who executed the command and user'snick
. Return false to ignore the unban, otherwise return true. For example:
function VH_OnUnBan (op, nick)
VH:SendToOpChat('LOGGER: ' .. op .. ' has just unbanned "' .. nick ..'"');
return 1;
end
Input parameters: 1= op, 2= nick
Note that in LUA functions you must put return 1 on the end of the function otherwise the hub will discard the action.
The input parameters are always strings and they never contains end-pipe
You can also use _PLUGINVERSION or _HUBVERSION global variable which will give the plugin and VerliHub version respectively
Method is called when a incoming chat message
arrives from user with nick
. Return false to ignore the protocol message and not to send it to all users, otherwise return true. For example:
function VH_OnParsedMsgChat (nick, data)
if nick == 'Mario' then
VH:SendToOpChat('MARIO has just wrote: "' .. data .. '"');
end
return 1
end
Input parameters: 1= nick, 2= message.
Method is called when a incoming private message
is sent to dest
from user with nick
. Return false to ignore the protocol message and not to send it to the user, otherwise return true. For example:
function VH_OnParsedMsgPM (nick, data, dest)
if nick == 'Mario' then
VH:SendToOpChat('MARIO has just wrote to ' .. dest ..' : "' .. data .. '"');
end
return 1
end
Input parameters: 1= nick, 2= message, 3= dest
Method is called when $Search message arrives from user with nick
with data
. This event cannot be discarded. For example:
function VH_OnParsedMsgSearch (nick, data)
if nick == 'Mario' then
VH:SendToOpChat('New $Search message from MARIO: "' .. data .. '"');
end
return 1
end
Input parameters: 1= nick, 2= data.
This method is called when a no-NMDC protocol message
arrives from user with nick
. If nick
is empty the method will return the ip
. Specifies with third argument is_nick
if it should be used the nick or IP. This event cannot be discarded. For example:
function VH_OnUnknownMsg (nick, message, 1)
VH:SendToOpChat('A new unknown message arrives from "' .. nick .. '": "' .. data .. '"');
return 1
end
Input parameters: 1= nick/ip, 2= message, 3= is_nick
This method is called when any type of data
arrives from user with nick
to the hub. For example when hub pinger enters in the hub:
function VH_OnParsedMsgAny (nick, message)
VH:SendToOpChat('nick: "' .. nick .. '" data: ' .. data);
return 1
end
you will see:
nick: "dchublist" data: $BotINFO DcHublistPinger
nick: "dchublist" data: $Version 1,0091
nick: "dchublist" data: $GetNickList
nick: "dchublist" data: $MyINFO $ALL dchublist DcHublistPinger<++ V:0.761,M:A,H:0/0/1,S:5>$ $Cable1$admin@dchublist.com$163353712394$
Return false to ignore the protocol message otherwise return true. Please be carefull with this event.
Please notice that this method is slighty different from OnParsedMsg* methods because this one is called before the message is processed as a protocol message.
Input parameters: 1= nick, 2= data
This method is called when a ConnectToMe data arrives from user with nick
to other_nick
. The method also provides the ip
and port
of the destination. For example:
function VH_OnParsedMsgConnectToMe (nick, other_nick, ip, port)
VH:SendToOpChat('New CTM from "' .. nick .. '": $ConnectToMe " .. other_nick.. " " .. ip .. ":" .. port);
return 1
end
$ConnectToMe message is sent by the user
nick
to userother_nick
in order to initiate a connection at the destinationip
:port
.
Input parameters: 1= nick, 2= othernick, 3= ip, 4= port
This method is called when nick
sends a RevConnectToMe data to other_nick
. Return false to ignore the protocol message and not to send it, otherwise return true. For example:
function VH_OnParsedMsgRevConnectToMe (nick, other_nick)
VH:SendToOpChat('"' .. nick .. '" has just sent a $RevConnectToMe to ' .. other_nick .. '"');
VH:SendToOpChat('$RevConnectToMe ' .. nick .. ' ' .. other_nick);
return 1
end
$RevConnectToMe message is sent by the passive user
nick
to the active userother_nick
in order to ask him to send the $ConnectToMe message.
Input parameters: 1= nick, 2= other_nick
This method is called when an incoming search_reply
arrives from a user with nick
. Return false to ignore the protocol message otherwise return true.
$SR message is sent by a client as a search reply to a previous $Search message
Input parameters: 1= nick, 2= search_reply
Called when $MyINFO data
arrives to the hub from nick
. Return false to ignore the protocol message otherwise return true. For example:
function VH_OnParsedMsgMyINFO (nick, data)
VH:SendToOpChat('New MyINFo from "' .. nick .. '": ' .. data);
return 1
end
If user Mario enters in the hub you will read in OPChat:
New MyINFO from "Mario": $MyINFO $ALL Mario <EiskaltDC++ V:2.2.7,M:A,H:0/0/3,S:3>$ $20$$15012006720$
Input parameters: 1= nick, 2= data
This method is called when a $Support message with data
arrives from user with nick
. Return false to ignore the protocol message otherwise return true.
$Supports message is used to negotiate protocol extensions, to indicate what extended features a client possesses.
Input parameters: 1= nick, 2= data
This method is called when $MyPass message arrives from user with nick
. It provides also the sent password in the data
variable. Return false to ignore the protocol message otherwise return true. For example:
function VH_OnParsedMsgMyPass (nick, data)
VH:SendToOpChat('User "' .. nick .. '" has just typed his password: ' .. data);
return 1
end
$MyPass message is sent by
nick
to the hub in response to $GetPass message and contains the password in the plain text format.
Input parameters: 1= nick, 2= data
This method is called when a $ValidateNick message arrives from ip
with nick
. Return false to ignore the protocol message otherwise return true.
ValidateNick message is sent by the client to the hub, after the client has received the $Key message.
Input parameters: 1= ip, 2= nick
This method is called when a new main chat message
is parsed. Message is sent by nick
to target_nick
. This method can be useful for anti-spam check.
Input parameters: 1= nick, 2= message, 3= target_nick
This method is called when user with ip
sends data
to the hub before login is completed. Return false to ignore the protocol message otherwise return true.
Input parameters: 1= ip, 2= data
This method is called when a $BotINFO message arrives from hublist pinger from user with nick
with data
. Return false to ignore the protocol message otherwise return true. For example:
function VH_OnParsedMsgBotINFO (nick, data)
VH:SendToOpChat('Pinger "' .. nick .. '" has just sent: ' .. data);
return 1
end
you will read in OPChat:
Pinger "dchublist" has just sent: $BotINFO DcHublistPinger
Input parameters: 1= nick, **2=**data
This method is called when a $Version message arrives from ip
with data
, where data represents the version of the DC client. Return false to ignore the protocol message otherwise return true. For example:
$Version message is sent by a client to a hub in response to the $Hello message sent by a hub.
Input parameters: 1= ip, 2= data
This method is called when user with nick
sends first $MyINFO during handshake. Additional information is returned.
Input parameters: 1= nick, 2= description+tag, 3= speed+status, 4= email, 5= sharesize
This method is called when a tag
is parsed and validated from user with nick
. Return false to close the user connection, otherwise return true.
Input parameters: 1= nick, 2= tag
Note that in LUA functions you must put return 1 on the end of the function otherwise the hub will discard the action.
The input parameters are always strings and they never contains end-pipe
You can also use _PLUGINVERSION or _HUBVERSION global variable which will give the plugin and VerliHub version respectively
Copyright © 2006-2024 Verlihub Team
Verlihub menu
- Verlihub Repository
- Wiki Home
- Installation
- Setup and Deployment
- Configuration
- Users
- Connections
- Messages
- Kicks and Bans
- Redirects
- Command List
- Variable List
- How-to
- FAQ's
- Utilities
Verlihub scripts