Yesterday, the cryptocurrency bot was born, and today, with just around 5 minutes work wrapping the API using PHP, the steemit bot is made 24/7 !
Type ?steem_id that will ask the steemit discord bot to query the steemit account.
Bugs report to @justyy the bot may be taken down sometime due to future upgrade and maintenance.
PHP Discord SteemIt Lookup Bot Source Code
<?php
ini_set('memory_limit', '200M');
include __DIR__.'/vendor/autoload.php';
require('valid.php');
use Discord\Discord;
$discord = new Discord([
'token' => 'YOUR-TOKEN'
]);
$discord->on('ready', function ($discord) {
$discord->on('message', function ($message, $discord) {
$msg = trim($message->content);
$cmd = strtolower($msg);
if (strlen($msg) <= 3) {
return;
}
if ($msg[0] != '?') {
return;
}
$user = trim(substr($msg, 1));
if (isValidId($user)) {
$url = "https://uploadbeta.com/api/steemit/account/profile/?id=$user";
$data = json_decode(file_get_contents($url), true);
$price_usd = 4;
$url2 = "https://api.coinmarketcap.com/v1/ticker/steem-dollars/";
$data2 = json_decode(file_get_contents($url2), true);
if ($data2) {
$price_usd = $data2[0]['price_usd'];
}
if ($data) {
$s = '@' . $user . "\n";
$s .= ' Reputation: ' . $data['rep'] . "\n";
$a = round($data['esp']['vesting_sp'], 3);
$b = round($data['esp']['received_sp'], 3);
$c = round($data['esp']['delegated_sp'], 3);
$s .= ' Effective Steem Power: ' . round($data['esp']['esp'],2) ."\n";
$s .= ' Steem Power: ' . $a ;
$s .= ' +' . $b ." ";
$s .= '-' . $c ." \n";
$s .= ' Voting Power: ' . round($data['vp'], 3) . "%\n";
$s .= ' Last Voted Time: ' . str_replace('T'," ",$data['last_vote_time']) . "\n";
$s .= ' STEEM: ' . round($data['steem'], 3) . "\n";
$s .= ' SBD: ' . round($data['sbd'], 3) . "\n";
$s .= ' Account Value: $' . round($data['value'] * $price_usd, 2) . "\n";
$s .= ' Account Age: ' . round($data['online']) . " Days\n";
$message->channel->sendMessage($s);
}
}
});
});
$discord->run();
Add steemit bot to your discord server:
https://discordapp.com/api/oauth2/authorize?client_id=418196534660694037&permissions=522304&scope=bot
Discord Welcome Bot – PHP Source
Update: The Discord Welcome Bot is also integrated:
Here is how it is written in PHP to welcome new members joining in Discord.
$discord->on('GUILD_MEMBER_ADD', function ($member, $discord) {
$newUserId = $member->user->id;
$guild = $discord->guilds->first();
$guild->channels->get("name", "general")->sendMessage("Welcome/欢迎 <@" . $newUserId . "> !");
});
You may also like: Discord 机器人 steemit 上线了!
–EOF (The Ultimate Computing & Technology Blog) —
Last Post: Introduction to the Discord Cryptocurrency-Lookup-Bot!
Next Post: Turtle Programming v0.0.5: Adding IF/ELSE and STOP!