Tcl Scripting

From IRCBotWiki

Jump to: navigation, search

An upcoming feature/plugin for IRCBot is the addition of Tcl Scripting. Those of you familiar with the Plugin API will notice the Tcl commands are a ported/simplified version of it.

However, there are of course some new commands specific to the Tcl scripts.

For example bind_event/unbind_event, see Tcl Events for more information on them.

unbind_all_events type
Removes all bound events of type - be careful though because Tcl has a global interpreter so it will remove the bound events from all scripts.
print string
You should use this instead of puts when possible because it will go through IRCBot's output buffering and logging.
SendPM netno nick/chan text
Sends a PM or channel text to IRC. You can also use the aliases msg or privmsg.
SendIRC netno text
Sends a raw IRC command to IRC.
GetBotNick netno
Get's the bot's nick on network netno. -1 is the bot's default nickname, 0+ is the bot's current nickname on that network.
GetBotVersion
The bot's version as a number.
GetBotVersionString
GetIP
Get the detected local IP.
GetPlatform
Get the current platform (Win32/Linux/etc.).
GetBasePath
Get the bot's working directory.
get_argc
Returns the argc value of the bot.
get_argv num
Returns item num from the argv[] array
LogToChan str
Send string to your LogChan (if defined).
Rehash fn
Rehash your ircbot.text (make fn "" to rehash the current ircbot.text, or specify a new filename to load a new one instead).
NumPlugins
Returns the number of loaded plugins
LoadPlugin fn
Load plugin with filename fn.
SendSock sock buf datalen
Send data to a socket
ClearSockEntries sock
Remove entries with socket sock from the SendQ.
IsValidUserName nick
Returns 1 if nick is a valid bot username, 0 otherwise.
GetUserNameFromHostmask hostmask
Returns the bot username associated with hostmask
GetUserLevel hostmask pass
Returns the user level associated with hostmask and pass (leave pass out or "" if you don't have the password)
GetUserPass nick
Returns the password associated with bot user nick
GetConfigSection parent name
Returns config sections, use NULL for parent for a root item

GetConfigSectionValue section name
Returns string config section value

GetConfigSectionLong section name
Returns integer config section value

IsConfigSectionValue section name
Returns 1 if value name is in section, 0 otherwise

Configuration Demo:
set sec [ GetConfigSection NULL "Base" ]
if { $sec != "NULL" } {
 set val [ IsConfigSectionValue $sec "Nick" ]
 print "IRCBot Nickname is set: $val\n"
 set val [ GetConfigSectionValue $sec "Nick" ]
 print "IRCBot Nickname: $val\n"
} else {
 print "Invalid section name!\n"
}
SendPluginMessage toplug MsgID data datalen
For MsgID see IPC Messages (all message ID's are set as constants in the Tcl interpreter).
NumNetworks
Returns the number of IRC networks that are set up.
IsNetworkReady netno
Returns 1 if IRC network netno is connected and logged in, 0 otherwise.
HasOwnerSupport netno
Returns 1 if IRC network netno supports owner/halfop/etc., 0 otherwise.
GetStreamInfo
How to use GetStreamInfo:

set info [ GetStreamInfo ];	
print "Current DJ: [ STATS_curdj_get $info ]\n";

See the STATS structure to see the available field names, you retrieve them the same way.


IRCBot vde

IRCBot main pages
Main PageInstallationChangelogCommandsPluginsFAQConfigurationCreditsRemote ClientBuffered SendBuilt-In VariablesMulti Sound Server Mode
Auto DJ Pages
Auto DJ Main PageWebRequest SystemSchedulerMP3 EncoderVoice SupportMySQL Plugin
IRCBot Programming vde

IRCBot Programming
Plugin APIIPC MessagesRemote CommandsPlugin InitializationIRCBot DB
Plugin API Functions (in Basic and Full)
ClearSockEntriesib_printfGetBotNickGetConfigSectionGetConfigSectionLongGetConfigSectionValueGetConfigSectionValueBufGetPluginGetUIGetUserLevelGetUserPassGetVersionGetVersionStringIsNetworkReadyLoadMessageLogToChanNumNetworksNumPluginsProcTextsafe_sleep_secondssafe_sleep_milliSendIRCSendMessageSendRemoteReplySendSock
Plugin API Functions (in Full only)
EnableRequestsGetSSInfoGetStreamInfo
Tcl Functions
Tcl ScriptingTcl Events
Plugin API Structures
API_commandsAPI_dbAPI_textfuncAPI_SSIRCBOT_UIPLUGIN_PUBLICSTATST_SOCKET

All structure references on this site are here as an aid and to give an idea of bot usage and may change drastically with IRCBot versions. Each copy of plugins.h is tied to a specific version of the bot, and other versions of structures may not be interchanged.

Personal tools