-
Notifications
You must be signed in to change notification settings - Fork 14
API Python Methods
NOTE: THIS FEATURE IS CURRENTLY NOT IMPLEMENTED IN PYTHON SCRIPTS
This method parses any hub or script command
as it is written by specified user with nick
. pm
specify if command
has been sent in PM or MC.
import vh
success = vh.ParseCommand(nick, command, pm)
The method returns a bool value.
Input parameters : 1= nick, 2= command, 3= pm
Sets the config variable
to the given value
for the specified configuration type
. Possible values for config type
can be "config" for hub configuration or "pi_pluginname" (replace pluginame with the name of plugin). The method returns a bool value. For example:
import vh
result = vh.SetConfig("config","max_chat_msg","0")
result = vh.SetConfig("pi_floodprot", "max_conn_per_ip", "2")
The first example will mute the main chat of the hub and the second one will change the max_conn_per_ip to two.
Input parameters: 1= config type, 2= variable, 3= value
This method returns the value of a given variable
for the specified configuration type
. Possible values for config type
can be "config" for hub configuration or "pi_pluginname" (replace pluginame with the name of plugin). For example:
import vh
desc = vh.GetConfig("config", "hub_desc")
maxconn = vh.GetConfig("pi_floodprot", "max_conn_per_ip")
where desc
in the first example will be the hub's description. The method returns None if the config variable does not exist.
Input parameters: 1= config type(str), 2= variable(str)
It returns the total share size in byte or none on fail.
import vh
bytes = int(vh.GetTotalShareSize())
gigabytes = (bytes * 1.0) / 1024**3
It returns the topic of the hub.
import vh
old_topic = vh.Topic()
new_topic = vh.Topic("Finally, it's the weekend!")
Input parameters: 1= topic
This method allows you to register a new bot in the hub with given nick
, class
, description
, speed
, email
and share
. For example:
import vh
vh.AddRobot ('Mario', 3, 'Hello users', 'DSL', 'newbot@myhub.com', 0)
Input parameters: 1= nick, 2= class, 3= description, 4= speed, 5= email, 6= share
This call remove the previously registered bot from the userlist with nick
. For example:
import vh
vh.DelRobot ('Mario')
Input parameters: 1= nick
It returns the number of all online users. Bots and registered bots will not be included in this list.
import vh
usercount = GetUsersCount()
This method returns the nicklist which contains all users in the hub. For example:
import vh
nicklist = vh.GetNickList()
first_three = nicklist[:3]
and first_three will become for example:
["user1", "user2", "user3"]
If you want to get a string with the raw NickList, use GetRawNickList instead.
import vh
nicklist = vh.GetRawNickList()
will store in nicklist:
$NickList user1$$user2$$user3$$usern$$
It will contain also the hub security and OPChat bots. It returns none on fail.
It returns the complete list of OPs including hub security and OPChat bots:
$OpList [SU]root$$Mario$$VerliHub$$OpChat$$
Returns the numeric value of class between 0 and 10 for the given nick
. For example:
import vh
class = vh.GetUserClass (nick);
if class < 5:
your code here .....
Input parameters: 1= nick
Returns with the host of the given user's nick
. For example:
import vh
def host(nick):
host = vh.GetUserHost (user)
if host and (len(host) > 0):
return host
else:
return 0
Input parameters: 1= nick
Returns the IP address for the given nick
. For example:
import vh
def getip(user):
userip = vh.GetUserIP(user)
if userip and (string.len (userip) > 0):
return userip
else:
return 0
Input parameters: 1= nick
Returns the Country Code (CC) for the given nick
. For example:
import vh
def getcc(user):
usercc = vh.GetUserCC (user)
if usercc or (usercc == "User not found"):
return 0
elif usercc == "":
return "Not found"
else:
return usercc
Input parameters: 1= IP
Returns the Country Code (CC) for the given ip
address. For example:
import vh
def getccfromip(ip):
usercc = vh.GetIPCC (ip)
if usercc or (usercc == "User not found"):
return 0
elif usercc == "":
return "Not found"
else:
return usercc
Input parameters: 1= ip
Returns the Country Name (CN) for the given ip
address. For example:
import vh
def getcnfromip(ip):
usercn = vh.GetIPCN(ip)
if usercn or (usercc == "User not found"):
return 0
elif usercn == "":
return "Not found"
else:
return usercn
Input parameters: 1= ip
It returns the full MyINFO string of the given nick
. For example:
import vh
myinfo = vh.GetMyINFO('Mario')
if myinfo and (len(myinfo) > 0):
return myinfo
else:
return 0
will return a string like this:
$MyINFO $ALL Mario [[2M/192K]]<++ V:0.698,M:A,H:0/0/1,S:3>$DSL?$no@spam.thx$152177393537$
Input parameters: 1= nick
Use this to remove a user from the hub with nick
. For example:
import vh
vh.Disconnect ('Mario')
will drop the given user.
Input parameters: 1= nick
This method restricts user's activity with nick
. For the other input parameters you should set the duration flag:
| Flag | Description| |-----------|------------|------------| |Empty value ("")|Don't change the restriction| |0|Unset the restriction| |1|Set the restriction to the default duration (2 days)| |Any other valid time value|You can specify the time value followed by time unit. To format the time please check this paragraph|
For more information about restrictions, please read Actions on user paragraph in the Manual. For example:
import vh
vh.UserRestrictions('Mario', '', 1, '3h', '')
This will prevent Mario to chat for 2 days and to search for 3 hours. Other restrictions will not be changed.
Input parameters: 1= nick, 2= nochattime, 3= nopmtime, 4= nosearchtime, 5= noctmtime
This method allow you to ban a user with the given nick
. You should also specify the duration
(in seconds) and the ban type flag
. The flag can be one of the following parameter:
| Flag | Description| |-----------|------------|------------| |0|Nick and IP address are banned| |1|IP address is banned| |2|Nick is banned| |3|Range address is banned| |4|Host of level 1 is banned| |5|Host of level 2 is banned| |6|Host of level 3 is banned| |7|Share is banned| |8|Prefix of nick is banned| |9|Reverse host is banned|
For example:
import vh
vh.Ban('Mario', 86400, 1)
Input paramters: 1= nick, 2= duration, 3= flag
This method allow you to kick a user with the given nick
with reason
. You should also specify the op
that should appear. For example:
import vh
vh.KickUser('Admin1', 'Mario', 'Faker!!')
vh.KickUser('Admin1', 'foobar', 'Spammer_BAN_2d')
As you can see from the second example you can also append the time at the end of the reason
Input paramters: 1= op, 2= nick, 3= reason
Sends MyINFO data (i.e. $HubIsFull) to a user with given nickname
. For example:
import vh
vh.SendDataToUser("$ForceMove redirectarray:no-ip.org:3333|", 'Mario')
vh.SendDataToUser("<HubSecurity> Your nickprefix is NOT correct, the allowed prefixs is: " + prefix + "|", 'Mario')
Remember to include the end pipe "|".
Input parameters: 1= data, 2= nick
This method sends a boadcast message
to all users which class is between min_class
and max_class
(including them) with nickname as_nick
. End-pipe after the data is needed. For example:
import vh
vh.SendPMToAll("<"+BotName+"> This is an example message|", 'OpChat', 3, 10)
Input parameters: 1= message, 2= as_nick, 3= min_class, 4= max_class
This methods will sends a MyINFO data
to a users which class is between min_class
and max_class
(including them). End-pipe after the data is needed. For example:
import vh
vh.SendDataToAll ("$OpList "..list.."|", 0, 10)
vh.SendDataToAll ("<Mario>" + string + "|", 5, 10)
vh.SendDataToAll ("$HubName This is my hub- And this is the topic" + "|", 0, 10)
Input parameters: 1= data, 2= min_class, 3= max_class
This method sends a new MyINFO string message to the hub. You should specify the nick
, the user's description
, tag
, speed
, email
and share
. For example:
import vh
vh.SetMyINFO('Mario', 'Hello users', '<ApexDC++ V:1.3.1,M:P,H:2/23/15,S:3>', 'DSL', 'new@myhub.com', 0)
Input parameters: 1= nick, 2= description, 3= tag, 4= speed, 5= email, 6= share
--
This method sends a new message
in the main chat of the hub with the BOT's name. For example:
import vh
vh.mc("Hey!! Please read our rules or FAQ if you need help")
Input parameters: 1= message
This method is similar to previous one but you can show the message
only to user whose class is between min_class
and max_class
values. For example:
import vh
vh.classmc("Hey!!", 2, 5)
This will show the message to VIPs, OPs, Cheefs and Admins only.
Input parameters: 1= message
This method sends a new message
in the main chat of the hub with the BOT's name to the given user with nick
. For example:
import vh
vh.usermc("Hey!! Please read our rules or FAQ if you need help")
Input parameters: 1= message, 2= nick
This method sends a new private message
(PM) to the given user with nick
. For example:
import vh
vh.pm("Hey!!", 'Mario')
Input parameters: 1= message, 2= nick
TODO
Input parameters: 1= query, 2= limit
NOTE: THIS FEATURE IS CURRENTLY NOT IMPLEMENTED IN PYTHON SCRIPTS
With this method you can run a query of your MySQL database. The method will return the number of total rows:
def runquery(query):
VH:SQLQuery ("DELETE FROM `reglist` WHERE `nick` = '".. nick .."' LIMIT 1")
UPDATE and DELETE queries returns as count 0
Input parameters: 1= query
NOTE: THIS FEATURE IS CURRENTLY NOT IMPLEMENTED IN PYTHON SCRIPTS
With this method you can retrieve data from selected rows with SQLQuery method. Row is the number of the row. For example:
import vh
rows = VH:SQLQuery ("SELECT `nick`, `class`, `reg_op` FROM `reglist` WHERE `nick` LIKE '%Mar%' ORDER BY `nick` ASC");
if rows > 0:
for x in rows:
result, nick, class, reg_op = vh.SQLFetch(x)
other code ....
Note that row indexes are zero based.
Input parameters: 1= row number
NOTE: THIS FEATURE IS CURRENTLY NOT IMPLEMENTED IN PYTHON SCRIPTS
It clears memory from last query requested with SQLQuery method. After this method SQLFetch will always result false.
This method converts the following characters to their applicable entities for the given string
:
Character | Entity |
---|---|
? |  |
$ | $ |
` | ` |
\ | | |
~ | ~ |
Input parameters: 1= string
This is the reverse method to Encode. It converts the previous entities to their applicable characters for the given string
:
Input parameters: 1= string
Copyright © 2006-2023 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