Exploring alternate ways to contribute to the community... (Part 2)

in #politics6 years ago

It's been about three months since first thinking about utility bot projects which was covered in the following blog posting:

https://steemit.com/cryptocurrency/@novacadian/exploring-alternate-ways-to-contribute-to-the-community

It kind of surprised me that it has been that long. Lots of high quality distractions. Everything seemed to be pushing me towards the Python programming language and their wonderful steem-python library for bot coding. You can find the full documentation of the steem-python library, in ptf format, at:

https://media.readthedocs.org/pdf/steem/latest/steem.pdf

Python is/was a new programming language for me so their was a little learning curve, yet things were moving along slowly and surely when it came to my attention that there was a Perl steem library as well! This would make things a lot easier for me, for as far back as the mid-90's Perl cgi programming was a full time job for me. There is tons of source of mine handling MySQL interfaces and the like on my server, which is likely to make the coding move ahead a lot more quickly. It could not be much slower than how long the Python research was taking. So that is the direction things have moved and have already had some quick results.

Started out with an example script in the perlsteemit library found at:

https://github.com/snkoehn/perlSteemit/blob/master/examples/example3.pl

The script was programmed to look for a tag 'utopian-io' and list the last 100 users which have posted with that tag and the average reputation of the grouping. My mods allows the user to pass the tag they want studied through the command line.

Script with mods:

#!/usr/bin/perl
use Modern::Perl;
use Data::Dumper;
use FindBin;
use lib "$FindBin::Bin/../lib";
use Steemit::WsClient;

#Get the tag to search through from the command line variable, ARG[0] and
#assign that value to variable arg_tag.
my $arg_tag = $ARGV[0];

#Print the search tag to console.
say "Tag : $arg_tag\n";

#Initialized Steemit client.
my $steem = Steemit::WsClient->new;
#say "Initialized Steemit client with url ".$steem->url;

#get the last 99 discussions with the search tag
#truncate the body since we dont care here
my $discussions = $steem->get_discussions_by_created({
tag => $arg_tag,
limit => 99,
truncate_body => 100,
});

#extract the author names out of the result
my @author_names = map { $_->{author} } @$discussions;
say "last 99 authors: ".join(", ", @author_names);

#load the author details
my $authors = $steem->get_accounts( [@author_names] );
#say Dumper $authors->[0];

#calculate the reputation average
my $reputation_sum = 0;
for my $author ( @$authors ){
$reputation_sum += int( $author->{reputation} / 1000_000_000 );
}
say "Average reputation of the last 99 $arg_tag authors: ". ( int( $reputation_sum / scalar(@$authors) ) / 100 );

The script can now be called from the command line of a Linux system (and probably from the COMMAND window on a Windoze system) providing the tag to search for as a command line variable like this:

$ ./steem-tag-users.pl ophumanangels

The script returned the following output as of the date of this posting:

Tag : ophumanangels

last 99 authors: apakapluk, itikna09, khaidir, miyardibarnura, khaidir, nafa.steem, kesling, apakapluk, davedickeyyall, ericedelweis, nafa.steem, azizbd, apakapluk, lyndsaybowes, miyardibarnura, neilur, hickorymack, chackett, phoenixwren, lyndsaybowes, khackett, thedarkhorse, nyakpui, chackett, nyakpui, luanne, apakapluk, hasanuddin, tobersteem, tober
Average reputation of the last 99 ophumanangels authors: 62.81steem

It could be useful to look for tags that the average user is below your rep; as then your upvote should have the greatest effect by my understanding. My plan is to use a tag to get my utility bot's attention.

Should you want to use the script you would need to have Perl and Steemit-WsClient module installed. It can be found on CPAN at:

http://search.cpan.org/~snkoehn/Steemit-WsClient-0.11/lib/Steemit/WsClient.pm

Keep on Steemin'!

Sort:  

Through this way we can easily to find tag and the authors that include there, that's amazing way @novacadian😉
You are amazing to do it!

The example script did most of the heavy lifting, but glad you liked my mods. 😎

😅😅😅😅
Yeah! Thank you about it @novacadian😂😆

From this post, it seems you're a programmer. Hope I'm right. Cheers!

Semi-retired at the moment yet having some fun with the steem-python library and Perl's Steemit::WsClient module. 😎

Hopefully the beginning of a utility bot idea.

I like the idea

Coin Marketplace

STEEM 0.29
TRX 0.12
JST 0.033
BTC 63855.79
ETH 3113.00
USDT 1.00
SBD 4.04