This site uses cookies. In order to read how we handle cookies please click here. Click on this message to accept and hide.
Перейти вверх
18.217.67.225.US

NDCH NDCH Lua API

Last updated: 2017.03.29

Table of contents

  1. Events
  2. Global methods
  3. Global objects
  4. Parameter objects
  5. SQLite Database
  6. SQLite Table

Events

onLoad()
When script loads
onUnload()
When script unloads
onTimer()
Called every ~ second.
onChatArrival(user=object, text=string)
When chat arrives from a user (return true to block sending)
onTextCommand(user=object, cmd=string, text=string)
On text command, all default with ! symbol. !help etc return true to block processing.
onDataArrival(user=object, cmd=string, text=string)
On protocol command/data, return true to ignore/do not process.
onUserConnect(user=object)
When user is validated/connect to hub
onUserDisconnect(user=object)
When a validated user disconnects from hub.
getHelp(user=object)
When a user calls help command.
getAbout()
When a user calls about command. Resulting string should be no more than 100 characters long.
publicProtocolMessage(data=text)
Called when public protocol messages are sent (this does not cover masked messages).

Global methods

print(...)
Print out to console/and or logfile
SQLiteDatabase('file.db')
Create or open sqlite database
createTask('lua code')
Create an asyncronous task.
nmdc_encode(str)
Encode string with escape characters $ and |
nmdc_decode(str)
Decode string to use characters $ and |
ip2ho(ip)
Convert string ip address to host address representation.
ip2no(ip)
Convert string ip address to net address representation.
no2ip(networkaddr)
Convert net address to string ip address.
ho2ip(hostaddr)
Convert host address to string ip address.
ho2cc(hostaddr)
Convert host address to 2-digit country code.

Global Objects

Hub
### (methods)

.getPID()
Get the process ID of the hub.
.newPermissions()
Create an empty permissions object for use with masks.
.newSupports()
Create an empty supports object for use with masks.
.sendToAll(text=string)
Send data to all users (can be data, no pipe needed)
.sendToAll(nick=string, text=string)
Send chat to all users from nick
.mSendToAll(pmask,smask=uint64, text=string)
Same as sendToAll but with permission and support mask.
.mSendToAll(pmask,smask=uint64, nick=string, text=string)
Same as sendToAll but with permission and support mask
.sendPMToAll(text=string)
Send pm to all users (default bot name is used as sender)
.sendPMToAll(nick=string, text=string)
Send pm to all users from nick
.mSendPMToAll(pmask,smask=uint64, text=string)
Same as sendPMToAll but with permission mask
.mSendPMToAll(pmask,smask=uint64, nick=string, text=string)
Same as above but with specified nick
.mSendPMToAll(pmask,smask=uint64, nick1,nick2=string, text=string)
Same as above but with from and display nick.
.mSendPMToAll(pmask,smask=uint64, nick1,nick2=string, text=string, ignoreUser=user)
Same as above but ignore user that is passed.
.sendToUser(user=object, text=string)
Send data to specified user
.sendToUser(user=object, nick=string, text=string)
Send chat to user from nick
.closeUser(user=object)
Drop user from hub (close connection)
.getUserByNick(nick=string)
Get a user object from nick, nil if not found
.banIP(ip=uint32, secs=uint32, op=string, reason=string)
Ban an ip (big endian uint32, e.g. 3232235877)
.banIP(ip=string, secs=uint32, op=string, reason=string)
Ban an ip by its corresponding string (e.g. 192.168.1.101)
.addBot(nick=string, description=string, email=string)
Add a bot to the list.
.removeBot(nick=string)
Remove a bot from the list.

### (properties)
.Uptime
Uptime in seconds
.UserCount
Current user count
.UserPeak
User peak count
.Name
Hub name.
.Topic
Hub topic.
.BotName
Hub default bot name.

Parameter Objects

User
### (methods)
.getPermissions()
Get permission object
.getSupports()
Get supports object

### (properties)
.nick
User validated nick
.ip
Integer based ipv4
.ipstr
String value of ipv4
.description
User description string
.connection
User connection string
.flag
User flag byte/char
.email
User email string
.sharesize
User share size in bytes
.validated
Validated, true or false
.client
Client string e.g. StrgDC++ V1...
.mode
Client mode A, P or S
.slots
Client slot count
.level
Get profile level number 0 guest, 1..x
.conn_time
Get date/time of login (in seconds).

Permissions
### (properties)
.mask
return the mask of this permissions object.
.reload_scripts
can reload lua scripts
.save_settings
can force settings/accounts save
.reload_settings
can reload hub config files (including accounts etc)
.manage_settings
can manage hub settings !set ....
.is_operator
this user is classified as an operator
.req_password
requires password to join
.use_commands
can use commands......
.has_key
has an operator key
.drop_users
can drop other users with !drop command
.kick_users
can kick users !kick ...
.redirect_users
can redirect users !redirect ...
.ban_users
can ban users
.unban_users
can unban users
.be_invisible
can be set invisible
.visible_ops
visible to operators (even if invisible)
.is_hidden
is hidden by default ?
.update_pass
can update own password
.chg_passwords
can update own password
.speak_main
can speak in main chat
.see_main
can see main chat
.send_pm
can send private messages
.reg_users
can register users and delete own regs
.del_accounts
can delete any accounts that have lower level
.no_chatspam_check
not checked for spamming main chat
.chg_hubname
can change hub name
.chg_hubtopic
can change hub topic
.chg_hubdesc
can change hub description
.chg_motd
can change hub motd
.chg_bot_info
can change bot security nick, desc etc
.whois
access to whois and seen commands
.opchat
can view/use opchat (if any)
.modes
can set modes (using mode scripts)
.tags
can view full tags
.changenick
can change nickname
.rename
can rename other users (lower or equal profile)
.userip
can view users ips
.no_share_req
can view users ips
.hubsharereq
share requirements
.hubsecurity
hub security config

Supports
### (properties)
.mask
get the mask of this supports object.
.OpPlus
...
.NoHello
...
.NoGetINFO
...
.DHT0
...
.QuickList
...
.BotINFO
...
.ZPipe0
...
.ChatOnly
...
.MCTo
...
.UserCommand
...
.BotList
...
.HubTopic
...
.UserIP2
...
.TTHSearch
...
.Feed
...
.ClientID
...
.IN
...
.BanMsg
...
.TLS
...
.SaltPass
...


SQLite Database

### (methods)
.tableExists(name=string)
Return true or false if table exists.
.execSQL('sql code')
Execute a statement without result.
.openSQL('sql code')
Execute a statement and return an [SQL table object].


SQLite Table

### (methods)
.Expand()
Return all columns as variables.
.First()
Move to first row.
.Next()
Move to next row.
.Last()
Move to last row.
.asInteger(col=integer)
Get column value as integer.
.asString(col=integer)
Get column value as string.
.asFloat(col=integer)
Get column value as floating point.

### (properties)
.EOF
True if there are no more rows available to method Next().
.Count
Total rows available.
.ColCount
Total columns available.

Комментарии

There are no comments for this page, you can leave one here.