View Single Post
Olly
Senior Member
Join Date: Mar 2007
Location: UK
Old 02-13-2008 , 18:08   Re: IRC Relay (v2.0.0)
Reply With Quote #4

Library Natives
v2.0.0 works by all of the seperate modules using the library natives here. And they will also work from any external plugin, you just need to include the irc-relay.inc file, which is in the download in the first post.

Forwards
OnIrcConnected
Code:
/*********************************************************
 *  Called when the bot is fully connected, and ready to 
 *  send commands and stuff to the server.
 * 
 * @noreturn        
 *********************************************************/
forward OnIrcConnected();
Does what it says on the tin, when the bot is connected, and ready to run commands on the server, this will be called in your plugin


OnRelayPm
Code:
/*********************************************************
 *  Called when someone sends a PM to the relay
 *
 * @noreturn        
 *********************************************************/
forward OnRelayPm();
OnRelayNotice
Code:
/*********************************************************
 *  Called when someone sends a NOTICE to the relay
 * 
 * @noreturn        
 *********************************************************/
forward OnRelayNotice();
OnRelayMessage
Code:
*********************************************************
 *  Called when someone sends a normal to the relay
 * 
 * @noreturn        
 *********************************************************/
forward OnRelayMessage();
OnUserQuit
Code:
/*********************************************************
 *  Called when someone quits from the IRC server
 * 
 * @noreturn        
 *********************************************************/
forward OnUserQuit();
OnWhoisHost
Code:
/*********************************************************
 *  Called after we receive a reply for host from a WHOIS command
 * 
 * @noreturn        
 *********************************************************/
forward OnWhoisHost();
Natives to get information about a forward, or command call
IRC_GetMsgSender
Code:
/*********************************************************
 *  Gets the nickname of the user who sent the message.
 * 
 * @param  String:buffer    The buffer to save the sender nickname into
 * @param  size            The size of the buffer
 * @noreturn
 *********************************************************/
native IRC_GetMsgSender(String:buffer[], size);
This, and following natives can be called from any command callback, or forward to get information of the person who triggered the command, or forward


IRC_GetSenderHost
Code:
/*********************************************************
 *  Gets the host of the user who sent the message. (ident@host)
 * 
 * @param  String:buffer    The buffer to save the senders host into
 * @param  size            The size of the buffer
 * @noreturn
 *********************************************************/
native IRC_GetSenderHost(String:buffer[], size);
IRC_GetMsgDestination
Code:
/*********************************************************
 *  Gets destination of the message, so we can send a message back to where it came from
 * 
 * @param  String:buffer    The buffer to save the destination into
 * @param  size            The size of the buffer
 * @noreturn
 *********************************************************/
native IRC_GetMsgDestination(String:buffer[], size);
The buffer will be set to the location any return message should be sent, so if the user called a command through a PM with the relay, then the buffer will contain the user's nickname, if it was called from a channel, then it will contain the channel name


IRC_GetMessage
Code:
/*********************************************************
 *  Gets the message, that was sent with the server response
 * 
 * @param  String:buffer    The buffer to save the message into
 * @param  size            The size of the buffer
 * @noreturn
 *********************************************************/
native IRC_GetMessage(String:buffer[], size);
Gets the message text that was sent, PM, or Channel Mssage


IRC_RegisterCommand
Code:
/*********************************************************
 *  Allows you to register your own irc command, and have
 *  it callback to a function in your plugin when it gets called
 *
 * @param    String:name[]          The name of the command to register
 * @param    function        The callback function in your plugin
 * @param    minAccess        The min access level a user needs to use the command (0 for disable)
 * @noreturn        
 *********************************************************/
functag IRC_Tag_CommandCallback public(argc);
native IRC_RegisterCommand(const String:name[], IRC_Tag_CommandCallback:function, const minAccess);
One of the main natives in the plugin. This will allow you to register your own command name (or add an extra action on an existing command). Once someone calls this function, then the callback specified will be called. Users must have a userlevel that = or > than the minAccess param, or the callback wont be run



IRC_ReplyMsg
Code:
/*********************************************************
 *  This will simply send a message to the same place that the triggering 
 *  command/message was sent from.
 *
 * @param    String:message[]    The message to send out.
 * @param     any:...            Formatter stuffs
 * @noreturn        
 *********************************************************/
native IRC_ReplyMsg(const String:message[], any:...);


IRC_ReplyNotice
Code:
/*********************************************************
 *  This will send a notice back to the origin of the triggering message
 *
 * @param    String:message[]    The message to send out.
 * @param     any:...            Formatter stuffs
 * @noreturn        
 *********************************************************/
native IRC_ReplyNotice(const String:message[], any:...);


IRC_Action
Code:
/*********************************************************
 *  This will show an 'action' in the specified channel, like /me [message]
 *
 * @param    String:destination[]      Can either be a channel name (#olly)
 *                     Or a nickname to send a PM
 * @param    String:message[]    The message to send out.
 * @param     any:...            Formatter stuffs
 * @noreturn        
 *********************************************************/
native IRC_Action(const String:destination[], const String:message[], any:...);

IRC_GetWhoisHost()
Code:
/*********************************************************
 *  Gets the hostname of the nickname that you whois'd this should be used inside the OnWhoisHost forward
 * 
 *  NOTE: If the specified nickname does not exist when the whois command was issued, then the host string will be left blank
 * 
 * @param  String:buffer    The buffer to save the host into
 * @param  size            The size of the buffer
 * @noreturn
 *********************************************************/
native IRC_GetWhoisHost(String:buffer[], size);


IRC_SendRaw
Code:
/*********************************************************
 *  This native will allow external plugins to send RAW 
 *  data to the server
 *
 * @param    String:command[]      The raw data to 
 *                     send to the IRC 
 *                     server.
 * @param     any:...            Formatting stuff
 * @noreturn        
 *********************************************************/
native IRC_SendRaw(const String:data[], any:...);
IRC_PrivMsg
Code:
/*********************************************************
 *  This will send a simple message to a user (pm) or 
 *  to a channel
 *
 * @param    String:destination[]      Can either be a channel name (#olly)
 *                     Or a nickname to send a PM
 * @param    String:message[]    The message to send out.
 * @param     any:...            Formatter stuffs
 * @noreturn        
 *********************************************************/
native IRC_PrivMsg(const String:destination[], const String:message[], any:...);
IRC_Notice
Code:
/*********************************************************
 *  This will send a simple notice to a user (pm) or 
 *  to a channel
 *
 * @param    String:destination[]      Can either be a channel name (#olly)
 *                     Or a nickname to send a PM
 * @param    String:message[]    The message to send out.
 * @param     any:...            Formatter stuffs
 * @noreturn        
 *********************************************************/
native IRC_Notice(const String:destination[], const String:message[], any:...);
IRC_Broadcast
Code:
/*********************************************************
 *  This will send a message to all of the channels of the type specified
 *
 * @param    ChannelType:ctype      The type of channel to send the message to
 * @param    String:message[]    The message to send out.
 * @param     any:...            Formatter stuffs
 * @noreturn        
 *********************************************************/
native IRC_Broadcast(ChannelType:ctype, const String:message[], any:...);
IRC_GetRelayNickName
Code:
/*********************************************************
 *  This will get the current nickname of the relay
 *
 * @param output    The buffer to store the name
 * @param size        The length of the buffer
 *********************************************************/
native IRC_GetRelayNickName(const String:output[], const size);
IRC_IsReady
Code:
/*********************************************************
 *  This will check if the core is correctly connected, and ready
 *
 * @return bool    True if the core is connected, and ready for commands        
 *********************************************************/
native IRC_IsReady();
IRC_GetCmdArgc
Code:
/*********************************************************
 *  Count the arguments sent along with our message
 *
 * @return count of arguments    
 *********************************************************/
native IRC_GetCmdArgc();
IRC_GetCmdArgv
Code:
/*********************************************************
 *  Get the argument number specified
 * 
 * @param  num        The arguemnt number to store
 * @param  String:arg    The buffer to save the argument in
 * @param  size        The size of the buffer
 * @noreturn
 *********************************************************/
native IRC_GetCmdArgv(num, String:arg[], size);
IRC_GetCmdArgString
Code:
/*********************************************************
 *  Will concatonate arguments starting at the specified argument
 *  and create a string. This is usefull for lazy people who
 *  dont put stuff in " "'s
 * 
 * @param  String:arg    The buffer to save the argument in
 * @param  size        The size of the buffer
 * @noreturn
 *********************************************************/
native IRC_GetCmdArgString(String:output[], size);
IRC_GetColourName | IRC_GetColorName
Code:
/*********************************************************
 *  Will return an IRC coloured version of the clients name
 * 
 * @param  client    The client index to get name for
 * @param  String:arg    The buffer to save the argument in
 * @param  size        The size of the buffer
 * @noreturn
 *********************************************************/
native IRC_GetColorName(client, String:output[], size);
stock IRC_GetColourName(client, String:output[], size) // Needs support for the REAL spelling of colour ;)
{
    IRC_GetColorName(client, output, size);
}
FindPlayerName
Code:
/*****************************************************************
 * FindPlayerName
 *
 * @breif Find the userid from name or partial name
 * @params String:name name of the player to search for
 * @return -1 on not found
 *           -2 on multiple matches
 *           id User id of the player
 *****************************************************************/
stock FindPlayerName(const String:name[]);
__________________
Tumblr Me: http://raspberryteen.tumblr.com


// Yarrrr!

Last edited by Olly; 03-07-2008 at 13:22.
Olly is offline
Send a message via MSN to Olly