Bot reference

From Botdom Documentation
Jump to: navigation, search

This is a technical reference on the most common methods in different bots.

PHP Bots

dAmnBot/NoodleBot xbot Futurism Contra
dAmn functions
Join <php-inline>$channel</php-inline> <php-inline>dAmn_Join( $channel );</php-inline> <php-inline>$sys_cl -> join( $channel );</php-inline> <php-inline>$dAmn -> joinRoom( $channel );</php-inline> <php-inline>$this -> dAmn -> join( $channel );</php-inline>
Part <php-inline>$channel</php-inline> <php-inline>dAmn_Part( $channel );</php-inline> <php-inline>$sys_cl -> part( $channel );</php-inline> <php-inline>$dAmn -> partRoom( $channel );</php-inline> <php-inline>$this -> dAmn -> part( $channel );</php-inline>
Say <php-inline>$msg</php-inline> in <php-inline>$channel</php-inline> with <php-inline>$type</php-inline> (msg, npmsg or action) <php-inline>dAmn_msg( $msg, $channel, $type );</php-inline> <php-inline>$sys_cl -> msg( $channel, $msg, $type );</php-inline> <php-inline>$dAmn -> say( $msg, $channel );</php-inline>

<php-inline>$dAmn -> me( $msg, $channel );</php-inline>

<php-inline>$dAmn -> npmsg( $msg, $channel );</php-inline>

<php-inline>$this -> dAmn -> say( $channel, $msg );</php-inline>

<php-inline>$this -> dAmn -> me( $channel, $msg );</php-inline>

<php-inline>$this -> dAmn -> npmsg( $channel, $msg );</php-inline>

Kick <php-inline>$user</php-inline> from <php-inline>$channel</php-inline> for <php-inline>$reason</php-inline> <php-inline>dAmn_Kick( $user, $channel, $reason );</php-inline> <php-inline>$sys_cl -> kick( $channel, $user, $reason );</php-inline> <php-inline>$dAmn -> kick( $user, $channel, $reason );</php-inline> <php-inline>$this -> dAmn -> kick( $channel, $user, $reason );</php-inline>
Promote/demote <php-inline>$user</php-inline> to <php-inline>$privclass</php-inline> in <php-inline>$channel</php-inline> N/A

<php-inline>$sys_cl -> promote( $channel, $user, $privclass );</php-inline>
<php-inline>$sys_cl -> demote( $channel, $user, $privclass );</php-inline>

<php-inline>$dAmn -> promote( $username, $privclass, $channel );</php-inline>
<php-inline>$dAmn -> demote( $username, $privclass, $channel );</php-inline>

<php-inline>$this -> dAmn -> promote( $channel, $username, $privclass );</php-inline>
<php-inline>$this -> dAmn -> demote( $channel, $username, $privclass );</php-inline>

Ban/unban <php-inline>$user</php-inline> from <php-inline>$channel</php-inline> N/A

<php-inline>$sys_cl -> ban( $channel, $username );</php-inline>
<php-inline>$sys_cl -> unban( $channel, $username );</php-inline>

<php-inline>$dAmn -> ban( $username, $channel );</php-inline>
<php-inline>$dAmn -> unban( $username, $channel );</php-inline>

<php-inline>$this -> dAmn -> ban( $channel, $username );</php-inline>
<php-inline>$this -> dAmn -> unban( $channel, $username );</php-inline>

Set <php-inline>$channel</php-inline>'s <php-inline>$property</php-inline> (topic or title) <php-inline>dAmn_Set( $channel, $property, $value );</php-inline> <php-inline>$sys_cl -> set( $channel, $property, $value );</php-inline> <php-inline>$dAmn -> set( $property, $value, $channel );</php-inline> <php-inline>$this -> dAmn -> set( $channel, $property, $value );</php-inline>
Admin function in <php-inline>$channel</php-inline> <php-inline>dAmn_Admin( $channel, $type, $typeval, $priv, $vals );</php-inline> (NoodleBot only) <php-inline>$sys_cl -> admin( $channel, $type, $typeval, $priv, $vals );</php-inline> <php-inline>$dAmn -> admin( $command, $channel );</php-inline> <php-inline>$this -> dAmn -> admin( $channel, $command );</php-inline>
Parses <php-inline>$priv</php-inline> (a channel privclass name or a channel privclass value) N/A

<php-inline>$sys_ch[$channel] -> parsePriv( $priv, $returnstring] )</php-inline>

  • <php-inline>$priv</php-inline> can be either a privclass name (string) or value (integer). The function returns the privclass value (integer) or name (string) depending on whether $returnstring is true or false/omitted.

.

.

Bot user functions
Get whois information for <php-inline>$user</php-inline> N/A
  • The function provided with dAmnBot/NoodleBot <php-inline>getinfo()</php-inline> is out-of-date for the current version of dAmn
<php-inline>$sys_cl -> whois( $user )</php-inline> <php-inline>$dAmn -> getUserInfo( $user )</php-inline>
  • Information will be stored in the variable <php-inline>$latestwhois[ $user ]</php-inline>.
<php-inline>$this -> dAmn -> get ( 'login:'.$user, 'info' );</php-inline>
  • Information can be retrieved from the events system.
See whether <php-inline>$user</php-inline> has <php-inline>$priv</php-inline> or more. <php-inline>user_has( $user, $priv )</php-inline> <php-inline>hasMinPriv( $user, $priv )</php-inline>

<php-inline>$sys_users[$user] -> hasMinPriv()*</php-inline>

  • *provided $user has already been registered with the bot
<php-inline>$user -> has( $user, $priv )</php-inline> <php-inline>$this -> User -> has( $user, $priv )</php-inline>
See whether <php-inline>$user</php-inline> has <php-inline>$priv</php-inline> or less. N/A
  • This made it so that to test whether a user was banned (had priv 0), you had to use !user_has($user,$priv+1).
<php-inline>hasMaxPriv( $user, $priv )</php-inline>

<php-inline>$sys_users[$user] -> hasMaxPriv()*</php-inline>

  • *provided $user has already been registered with the bot
None yet. N/A
Parses <php-inline>$priv</php-inline> (a bot privclass name or a bot privclass value) N/A

<php-inline>parsePriv( $priv, $returnstring )</php-inline>

  • <php-inline>$priv</php-inline> can be either a privclass name (string) or value (integer). The function returns the privclass value (integer) or name (string) depending on whether $returnstring is true or false/omitted.

<php-inline>$user -> getClassNameFromId( $id )</php-inline>

<php-inline>$user -> getClassIdFromName( $name )</php-inline>

<php-inline>$this -> User -> class_name ( $priv );</php-inline>

<php-inline>$this -> User -> class_order ( $priv );</php-inline>

System variables
Channel data

<php>$properties = array (

channel = array (
 "title", "topic" = array (
  p,
  by,
  ts,
  data
 ),
 "privclasses" = array (
  number => name,
  name => number,
 ),
 "members"/**/ = array (
  name => array (
   pc,
   usericon,
   symbol,
   realname,
   typename,
   gpc,
   count
  ),
 "privclassmembers"/***/ = array (
  privclassname => array (
   membername
  )
 )
)

)</php>

  • <php-inline>/**/</php-inline> Members currently in the room
  • <php-inline>/***/</php-inline> Only if obtained via /admin show users and /admin show privclass

<php>$sys_ch = array(

$channel => dAmnChan (
 name,
 title,topic = array (
  p,
  by,
  ts,
  data,
 ),
 members* = array (
  name => array (
   pc,
   count,
  )
 ),
 pcs = array (
  number => array (
   name,
   perms**,
   members** => array(),
  )
 )
)

)</php>

  • *Members currently in the room
  • **Only if obtained via /admin show users and /admin show privclass

Still unfinished. <php>$properties = array(

"c" => array(
 $channel => array(
  "ti" => $title,
  "to" => $topic,
  "pc" => $privclasses,
  "u" => $users
 )
),
"u" => array(
), // Unfinished, probably reorganizing

);</php>

<php>$this -> dAmn -> chat = array (

 $channel = array (
   'title', 'topic' = array (
     'content' = content,
     'by' = by,
     'ts' = timestamp,
   ),
   'pc' = array (
     privilege_class_order = privilege_class_name
   ),
   'member' = array (
     username = array (
       'con' = number_of_connections,
       'symbol' = username_symbol,
       'pc' = privilege_class
     )
   )
 )

)</php>

User data

<php>$users = array (

$name => priv,

)</php>

<php>$sys_users = array (

$name => User (
 name,
 priv,
 info => array (
  usericon,
  symbol,
  realname,
  typename,
  gpc,
 )
 connections* => array (
  $index => array (
   online,
   onlinesince,
   idle,
   channels => array(),
  )
 )
)

)</php>

  • *Only if obtained via /whois [username]

<php>$user->users = array (

$privclassNumber = array (
 "__classname" => $privclassName,
 $username => $privclassNumber,
 // repeat
)
// repeat

)</php>

Event data Assortment of variables. See process.php

<php>$sys_trg* = array (

type,
mod,
subj,
obj,
chan,
cmd,
args,

)</php>

  • *Data within $sys_trg is re-set every time an event/command is triggered.
  • *Data within $sys_trg is also copied into multiple single-value variables for easy access. See xbot/Modules#Accessing event data for details.