Skip to content

Instantly share code, notes, and snippets.

@NuckChorris
Created August 13, 2012 05:39
Show Gist options
  • Select an option

  • Save NuckChorris/3337213 to your computer and use it in GitHub Desktop.

Select an option

Save NuckChorris/3337213 to your computer and use it in GitHub Desktop.
<?php
class cb_module extends extension {
public $name = 'TestCallback';
public $version = 1;
public $about = 'BDS-backed last-seen function';
public $status = true;
public $author = 'nuckchorris0';
private $cb;
function init() {
$this->addCmd('botinf', 'c_botinfo');
$this->cmdHelp(
'botinf',
'Get bot information'
);
}
function c_botinfo($ns, $requestor, $message) {
$bot = strtolower(args($message, 1));
if (!$bot) {
$this->dAmn->say($ns, "<abbr title=\"{$requestor}\"></abbr> You must specify the name of a bot you wish to get information for.");
} else {
$this->dAmn->npmsg('chat:DataShare', "BDS:BOTCHECK:REQUEST:{$bot}", true);
$dAmn = $this->dAmn;
$this->hookOnceBDS(function ($parts, $from, $message) use ($ns, $requestor, $dAmn) {
// BDS:BOTCHECK:INFO:roleymoley,Contra,5.4.7/0.3,nuckchorris0,$
$data = explode(',', $parts[3], 5);
$versions = explode('/', $data[2]);
$owners = explode(';', $data[3]);
$info = array(
'username' => $data[0],
'bottype' => $data[1],
'botversion' => $versions[0],
'bdsversion' => $versions[1],
'owners' => $owners,
'trigger' => $data[4]
);
if($dAmn->chat['chat:DataShare']['member'][$from]['pc'] !== 'PoliceBot') return;
if(strstr($info['trigger'], '&amp;') || strstr($info['trigger'], '&lt;') || strstr($info['trigger'], '&gt;'))
$info['trigger'] = trim(htmlspecialchars_decode($info['trigger'], ENT_NOQUOTES));
$sb = '<sub>';
$sb .= "Bot Username: [<b>:dev{$info['username']}:</b>]<br>";
$sb .= "Bot Owner: [<b>:dev" . implode($info["owners"], ":</b>], [<b>:dev") . ":</b>]<br>";
$sb .= "Bot Version: <b>{$info['bottype']} <i>{$info['botversion']}</i></b><br>";
$sb .= "BDS Version: <b>{$info['bdsversion']}</b><br>";
$sb .= "Bot Trigger: <b>" . implode("</b><b>", str_split($info["trigger"])) . "</b><br>";
$sb .= "</sub><abbr title=\"{$requestor}\"> </abbr>";
$dAmn->say($ns, $sb);
}, 'BDS:BOTCHECK:INFO:' . $bot . '*');
}
}
}
new cb_module($core);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment