Bot class

The Bot class represents a 'bot' (a bot will apear as an operator in the nicklist of the hub).
Hex.Bot() returns a new object of type Bot.

A bot will only remain registered with the hub (visible to users), as long as the Bot object you created is valid.
Once the object gets collected by the lua garbage collector then the bot will automatically be unregistered.

If a user sends a PM (private message) to the bot The OnPmToBot(iBotId, iUserId, sData) callback will be called in your script.
A script is not required to process messages sent in PM to a bot.

Bot:Register(sNick)

This function registers the bot with the hub.
This function returns true on success and false on failure.

Remarks:
A registered bot may or may not be renamed upon registration with hexhub, for example if the nickname is already taken. An operator of the hub may use the !rename trigger to rename the bot, and therefore you should always use the bot:GetNick() function to determine the nickname of your bot if your script depends on the nickname used to register the bot.

Parameters:

Bot:Unregister()

This function unregisters the bot.
This function does not return a value.

Bot:GetBotId()

This function returns the HeXHub ID of the bot.

Bot:GetNick()

This function returns the nickname of the bot.

Lua script sample

mybot = nil

function OnLoad()
	-- Create a new bot object
	mybot = Hex.Bot()
	
	-- Register the bot with the hub
	if mybot:Register("FuckingBot") == true then
		-- The bot was succesfully registered
	else
		-- The bot was not registered
	end

	-- Check the nickname of the bot just in case it was renamed
	if mybot:GetNick() ~= "FuckingBot" then
		print("Bot registered, but renamed to: "..mybot:GetNick())
	end
end

Generated on Thu Aug 21 11:24:07 2008 for HeXHub/HexScript by  doxygen 1.5.4
Site hosted by SourceForge.net Logo