Modules/SebasIRC/ircPart: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: {{ml_irc}} __NOTOC__ {{ModuleFunction|SebasIRC}} This function will part the bot from a channel ==Syntax== <syntaxhighlight lang="lua"> bool ircPart(string channel) </syntaxhighlight> ===Required arguments=== * '...)
 
mNo edit summary
 
(2 intermediate revisions by one other user not shown)
Line 7: Line 7:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool ircPart(string channel)
bool ircPart ( string channel [, string reason = "" ] )
</syntaxhighlight>
</syntaxhighlight>
===Required arguments===
===Required arguments===
* '''channel:''' The channel name to part.
* '''channel:''' The channel name to part.
===Optional Arguments===
{{OptionalArg}}
*'''reason:''' The part reason.


===Returns===
===Returns===
True.
Returns true, otherwise false when giving wrong arguments.


==Example==
==Example==
Line 21: Line 25:
addEventHandler("onResourceStart", getResourceRootElement(),
addEventHandler("onResourceStart", getResourceRootElement(),
   function()
   function()
     if ircConnect("irc.mtasa.com", 6667) then
     if ircConnect("irc.mtasa.com", 6667, "echoBot") then
       bot = true
       bot = true
       ircJoin("#mta.echo")
       ircJoin("#mta.echo")
Line 32: Line 36:
     if channel == nil then return end
     if channel == nil then return end
      
      
     if bot and ircConnected() then
     if bot and ircIsConnected() then
       ircPart(tostring(channel))
       ircPart(tostring(channel))
       outputChatBox("-IRC- Parted: "..tostring(channel).."!")
       outputChatBox("-IRC- Parted: "..tostring(channel).."!")
Line 39: Line 43:
)
)
</syntaxhighlight>
</syntaxhighlight>
[[pl:Modules/SebasIRC/ircPart]]


==See also==
==See also==
{{Modules/SebasIRC/Functions}}
{{Modules/SebasIRC/Functions}}

Latest revision as of 16:37, 21 July 2016


Package-x-generic.png This function is provided by the external module SebasIRC. You must install this module to use this function.


This function will part the bot from a channel

Syntax

bool ircPart ( string channel [, string reason = "" ] )

Required arguments

  • channel: The channel name to part.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • reason: The part reason.

Returns

Returns true, otherwise false when giving wrong arguments.

Example

local bot = nil

addEventHandler("onResourceStart", getResourceRootElement(),
  function()
    if ircConnect("irc.mtasa.com", 6667, "echoBot") then
      bot = true
      ircJoin("#mta.echo")
    end
  end
)

addCommandHandler("part",
  function(thePlayer, command, channel)
    if channel == nil then return end
    
    if bot and ircIsConnected() then
      ircPart(tostring(channel))
      outputChatBox("-IRC- Parted: "..tostring(channel).."!")
    end
  end
)

See also

Connection:

Channel:

Bot: