56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace mt;
|
|
|
|
use phpcommon;
|
|
|
|
class Robot {
|
|
|
|
public static function get($id)
|
|
{
|
|
return array_key_exists($id, self::getMetaList()) ? self::getMetaList()[$id] : null;
|
|
}
|
|
|
|
public static function getRandMember()
|
|
{
|
|
$meta = self::get(1000 + rand(1, 100));
|
|
return array(
|
|
'account_id' => $meta['id'],
|
|
'name' => $meta['name'],
|
|
'avatar_url' => $meta['avatar_url'],
|
|
);
|
|
}
|
|
|
|
public static function getSinMembers()
|
|
{
|
|
$members = array();
|
|
foreach (self::getMetaList() as $meta) {
|
|
array_push($members, array(
|
|
'name' => $meta['name'],
|
|
'avatar_url' => $meta['avatar_url'],
|
|
));
|
|
}
|
|
return $members;
|
|
}
|
|
|
|
public static function traverse($cb)
|
|
{
|
|
foreach (self::getMetaList() as $meta) {
|
|
if (!$cb($meta)) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected static function getMetaList()
|
|
{
|
|
if (!self::$metaList) {
|
|
self::$metaList = getMetaTable('robot@robot.php');
|
|
}
|
|
return self::$metaList;
|
|
}
|
|
|
|
protected static $metaList;
|
|
|
|
}
|