Holger avatar

update for beem: add community support

holger80

Published: 14 Jul 2020 › Updated: 14 Jul 2020update for beem: add community support

update for beem: add community support

Repository

https://github.com/holgern/beem


beem-logo

beem is a python library and command line tool for HIVE. The current version is 0.24.5.

There is also a discord channel for beem: https://discord.gg/4HM592V

The newest beem version can be installed by:

pip install -U beem

Check that you are using hive nodes. The following command

beempy updatenodes --hive

updates the nodelist and uses only hive nodes. After setting hive as default_chain, beempy updatenodes can be used.

The list of nodes can be checked with

beempy config

and

beempy currentnode

shows the currently connected node.

Changelog for versions 0.24.5

  • replace percent_hive_dollars by percent_hbd (to make beem HF24 ready)
  • Remove whaleshares related code
  • Fix adding of a wif in beempy
  • Remove SteemConnect
  • Fix set token in HiveSigner
  • Add Blurt
  • Add Community for community reladed requests and broadcasts
  • Improve community lookup for beempy createpost
  • Improved beempy history command output
  • Improved beempy stream

Community support

I added community support to beem. The following example shows the content of a community dict:

from beem.community import Community
from prettytable import PrettyTable
community = Community("hive-139531")
t = PrettyTable(["key", "value"])
t.align = "l"
t._max_width = {"value" : 60}
for key in community.json():
    t.add_row([key, community.json()[key]])
print(t)

returns

+-------------+--------------------------------------------------------------+
| key         | value                                                        |
+-------------+--------------------------------------------------------------+
| id          | 1357761                                                      |
| name        | hive-139531                                                  |
| title       | HiveDevs                                                     |
| about       | HiveDevs - A community of developers working on Hive related |
|             | projects. Visit our Discord at https://discord.gg/cvnByhu    |
| lang        | en                                                           |
| type_id     | 1                                                            |
| is_nsfw     | False                                                        |
| subscribers | 1005                                                         |
| sum_pending | 638                                                          |
| num_pending | 253                                                          |
| num_authors | 120                                                          |
| created_at  | 2020-01-23 16:27:39                                          |
| avatar_url  |                                                              |
| context     | {}                                                           |
| description |                                                              |
| flag_text   |                                                              |
| settings    | {}                                                           |
| team        | [['hive-139531', 'owner', ''], ['netuoso', 'admin', ''],     |
|             | ['abit', 'mod', ''], ['roadscape', 'mod', ''], ['acidyo',    |
|             | 'mod', ''], ['gtg', 'mod', ''], ['good-karma', 'mod',        |
|             | 'Founder of Esteem'], ['jesta', 'mod', ''], ['inertia',      |
|             | 'mod', '#1138'], ['arcange', 'mod', ''], ['someguy123',      |
|             | 'mod', ''], ['mahdiyari', 'mod', ''], ['blocktrades', 'mod', |
|             | ''], ['drakos', 'mod', ''], ['themarkymark', 'mod', ''],     |
|             | ['stoodkev', 'mod', ''], ['therealwolf', 'mod', ''],         |
|             | ['yabapmatt', 'mod', ''], ['eonwarped', 'mod', ''],          |
|             | ['emrebeyler', 'mod', ''], ['bobinson', 'mod', ''],          |
|             | ['asgarth', 'mod', ''], ['quochuy', 'mod', 'Witness'],       |
|             | ['crimsonclad', 'mod', ''], ['pharesim', 'mod', '']]         |
+-------------+--------------------------------------------------------------+

The following API functions have been implemented:

roles = community.get_community_roles()
print("len %d - first entry: %s" % (len(roles), str(roles[0])))
subscribers = community.get_subscribers()
print("len %d - first entry: %s" % (len(subscribers), str(subscribers[0])))
last_activity = community.get_activities(limit=100, last_id=None)
print("len %d - first entry: %s" % (len(last_activity), str(last_activity[0])))
latest_post = community.get_ranked_posts(limit=25)
print("len %d - first entry: %s" % (len(latest_post), str(latest_post[0])[:120]))

returns:

len 50 - first entry: ['hive-139531', 'owner', '']
len 250 - first entry: ['joshman', 'guest', None, '2020-07-14 16:16:15']
len 100 - first entry: {'id': 78159733, 'type': 'subscribe', 'score': 35, 'date': '2020-07-14T16:16:15', 'msg': '@joshman subscribed to HiveDevs', 'url': 'trending/hive-139531'}
len 25 - first entry: {'post_id': 83702748, 'author': 'netuoso', 'permlink': 'creation-of-steemdevs-community-information-about-steemdevs', 'c

get_subscribers() returns only 250 subscribers and it is currently not possible to receive all subscribers (hive-139531 has 1005 subscribers in total). A way to receive all subscribers could be parsing get_activities, as there is an entry for each new subscriber.

Communities

Communities returns a list of registred communities. The communities inside the list can be printed by printAsTable() and it is possible to search the community title for a match:

from beem.community import Communities
communities = Communities(limit=100)
communities.search_title("dev").printAsTable()

returns

+-----+-------------+----------+------+-------------+-------------+-------------+-------------+
| Nr. | Name        | Title    | lang | subscribers | sum_pending | num_pending | num_authors |
+-----+-------------+----------+------+-------------+-------------+-------------+-------------+
| 1   | hive-139531 | HiveDevs | en   | 1000        | 945         | 236         | 113         |
+-----+-------------+----------+------+-------------+-------------+-------------+-------------+

The limit of returned communities can be increased by using the limit parameter:

from beem.community import Communities
communities = Communities(limit=1000)
communities.search_title("dev").printAsTable()

returns

+-----+-------------+---------------+------+-------------+-------------+-------------+-------------+
| Nr. | Name        | Title         | lang | subscribers | sum_pending | num_pending | num_authors |
+-----+-------------+---------------+------+-------------+-------------+-------------+-------------+
| 1   | hive-139531 | HiveDevs      | en   | 1000        | 945         | 236         | 113         |
| 2   | hive-152825 | DEVCOIN       | en   | 2           | 0           | 5           | 2           |
| 3   | hive-199094 | Devotionals   | en   | 1           | 0           | 3           | 1           |
| 4   | hive-192808 | kr-dev-center | kr   | 20          | 0           | 0           | 0           |
| 5   | hive-150008 | Game Dev   | en   | 12          | 0           | 0           | 0           |
| 6   | hive-101482 | BeeWiki.Dev   | en   | 6           | 0           | 0           | 0           |
+-----+-------------+---------------+------+-------------+-------------+-------------+-------------+

Searching a community by its title was also added to beempy createpost
alt
Currently a title is searched in the top 1000.

Broadcasting community related ops

The following shows all operation that can be broadcasted:

from beem.community import Community
community = Community("hive-111111")
community.set_role("account_a", "mod", "new mod")
community.set_user_title("account_b", "investor")
community.mute_post("author_a", "permlink_a", "spam", "mod_a")
community.unmute_post("author_a", "permlink_a", "no spam", "mod_a")
community.update_props("My Community", "Great community", False, "About me", "Not about me", "admin_a")
community.subscribe("user_c")
community.unsubscribe("user_c")
community.pin_post("author_a", "permlink_a", "mod_a")
community.unpin_post("author_a", "permlink_a", "mod_a")
community.flag_post("author_a", "permlink_a", "please check", "user_a")

HiveSigner / steemconnect

I removed the SteemConnect class from beem, as steemconnect.com is no longer working.

I fixed the token parameter in HiveSigner:

from beem.HiveSigner import HiveSigner
hs = HiveSigner(token=["32..."])
print(hs.me())

where 32... is a valid HiveSinger token.

Improved beempy stream

beempy stream -t -f

retuns now a table for each block:

+----------+---------+-------------+------------------------------------------------------+
| blocknum | trx_num | type        | content                                              |
+----------+---------+-------------+------------------------------------------------------+
| 45157440 | 0       | custom_json | sm_submit_team                                       |
| 45157440 | 1       | custom_json | sm_find_match                                        |
| 45157440 | 2       | vote        | 100.00% @mattsanthonyit/uty6wgup4ul - mattsanthonyit |
| 45157440 | 3       | custom_json | sm_find_match                                        |
| 45157440 | 4       | custom_json | sm_find_match                                        |
| 45157440 | 5       | custom_json | sm_find_match                                        |
| 45157440 | 6       | custom_json | sm_find_match                                        |
| 45157440 | 7       | custom_json | sm_find_match                                        |
| 45157440 | 8       | custom_json | sm_find_match                                        |
| 45157440 | 9       | custom_json | sm_submit_team                                       |
| 45157440 | 10      | custom_json | sm_submit_team                                       |
| 45157440 | 11      | custom_json | sm_find_match                                        |
| 45157440 | 12      | custom_json | sm_find_match                                        |
| 45157440 | 13      | custom_json | sm_find_match                                        |
| 45157440 | 14      | custom_json | scot_claim_token                                     |
| 45157440 | 15      | vote        | 5.00% @xr-hammergaming/52ktvx97870 - innerhive       |
| 45157440 | 16      | custom_json | sm_find_match                                        |
+----------+---------+-------------+------------------------------------------------------+

where custom_json, vote, transfer and transfer_to_vesting have a shortened output.

beempy stream -f

streams the output in raw format.

Blurt

As some beem users were interested in using beem on blurt, I added a Blurt class to beem. This adds support for blurt to beempy.
The following commands will change the nodes, and check if they are set

beempy updatenodes --blurt
beempy config

It is then possible to check the amount of powered up BLURT and to power it down by

beempy power holger80
beempy powerdown -a holger80 33244

The powerdown command will ask for your active keys.

You can check the activity on blurt by

beempy stream -t

you need to be patient, as there is currently not much activity...:

{'block_num': 306762,
 'op': ['withdraw_vesting',
        {'account': 'oth1',
         'vesting_shares': {'amount': '36699505048',
                            'nai': '@@000000037',
 'timestamp': '2020-07-14T21:53:57',
 'trx_num': 0}
{'block_num': 306765,
 'op': ['vote',
        {'author': 'discernente',
         'permlink': '0alhcnfp0r7dh2t',
         'voter': 'discernente',
         'weight': 10000}],
 'timestamp': '2020-07-14T21:54:06',
 'trx_num': 0}

You can switch back to hive with:

beempy updatenodes --hive

The Blurt class can be used to simplify the access to the Blurt blockchain:

from beem import Blurt
blurt = Blurt(node= ["https://rpc.blurt.world", "https://blurt-rpc.steem.buzz"])
print(blurt)

returns

<Blurt node=https://rpc.blurt.world, nobroadcast=False>

If you like what I do, consider casting a vote for me as witness on Hivesigner or on PeakD

Leave update for beem: add community support to:

Written by

beem Developer, Hive Witness, beempy.com, rewarding.app

Read more #development posts


Best Posts From Holger

We have not curated any of holger80's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Holger