bhive.comment module

class bhive.comment.Comment(authorperm, use_tags_api=True, full=True, lazy=False, hive_instance=None)

Bases: bhive.blockchainobject.BlockchainObject

Read data about a Comment/Post in the chain

Parameters
  • authorperm (str) – identifier to post/comment in the form of @author/permlink

  • use_tags_api (boolean) – when set to False, list_comments from the database_api is used

  • hive_instance (Hive) – bhive.hive.Hive instance to use when accessing a RPC


>>> from bhive.comment import Comment
>>> from bhive.account import Account
>>> from bhive import Hive
>>> hv = Hive()
>>> acc = Account("gtg", hive_instance=hv)
>>> authorperm = acc.get_blog(limit=1)[0]["authorperm"]
>>> c = Comment(authorperm)
>>> postdate = c["created"]
>>> postdate_str = c.json()["created"]
property author
property authorperm
property body
property category
curation_penalty_compensation_HBD()

Returns The required post payout amount after 15 minutes which will compentsate the curation penalty, if voting earlier than 15 minutes

delete(account=None, identifier=None)

Delete an existing post/comment

Parameters
  • account (str) – (optional) Account to use for deletion. If account is not defined, the default_account will be taken or a ValueError will be raised.

  • identifier (str) – (optional) Identifier for the post to delete. Takes the form @author/permlink. By default the current post will be used.

Note

A post/comment can only be deleted as long as it has no replies and no positive rshares on it.

property depth
downvote(weight=100, voter=None)

Downvote the post

Parameters
  • weight (float) – (optional) Weight for posting (-100.0 - +100.0) defaults to -100.0

  • voter (str) – (optional) Voting account

edit(body, meta=None, replace=False)

Edit an existing post

Parameters
  • body (str) – Body of the reply

  • meta (json) – JSON meta object that can be attached to the post. (optional)

  • replace (bool) – Instead of calculating a diff, replace the post entirely (defaults to False)

estimate_curation_HBD(vote_value_HBD, estimated_value_HBD=None)

Estimates curation reward

Parameters
  • vote_value_HBD (float) – The vote value in HBD for which the curation should be calculated

  • estimated_value_HBD (float) – When set, this value is used for calculate the curation. When not set, the current post value is used.

get_all_replies(parent=None)

Returns all content replies

get_author_rewards()

Returns the author rewards.

Example:

{
    'pending_rewards': True,
    'payout_HP': 0.912 HIVE,
    'payout_HBD': 3.583 HBD,
    'total_payout_HBD': 7.166 HBD
}
get_beneficiaries_pct()

Returns the sum of all post beneficiaries in percentage

get_curation_penalty(vote_time=None)

If post is less than 15 minutes old, it will incur a curation reward penalty.

Parameters

vote_time (datetime) – A vote time can be given and the curation penalty is calculated regarding the given time (default is None) When set to None, the current date is used.

Returns

Float number between 0 and 1 (0.0 -> no penalty, 1.0 -> 100 % curation penalty)

Return type

float

get_curation_rewards(pending_payout_HBD=False, pending_payout_value=None)

Returns the curation rewards.

Parameters
  • pending_payout_HBD (bool) – If True, the rewards are returned in HBD and not in HIVE (default is False)

  • pending_payout_value (float, str) – When not None this value instead of the current value is used for calculating the rewards

pending_rewards is True when the post is younger than 7 days. unclaimed_rewards is the amount of curation_rewards that goes to the author (self-vote or votes within the first 30 minutes). active_votes contains all voter with their curation reward.

Example:

{
    'pending_rewards': True, 'unclaimed_rewards': 0.245 HIVE,
    'active_votes': {
        'leprechaun': 0.006 HIVE, 'timcliff': 0.186 HIVE,
        'st3llar': 0.000 HIVE, 'crokkon': 0.015 HIVE, 'feedyourminnows': 0.003 HIVE,
        'isnochys': 0.003 HIVE, 'loshcat': 0.001 HIVE, 'greenorange': 0.000 HIVE,
        'qustodian': 0.123 HIVE, 'jpphotography': 0.002 HIVE, 'thinkingmind': 0.001 HIVE,
        'oups': 0.006 HIVE, 'mattockfs': 0.001 HIVE, 'thecrazygm': 0.003 HIVE, 'michaelizer': 0.004 HIVE,
        'flugschwein': 0.010 HIVE, 'ulisessabeque': 0.000 HIVE, 'hakancelik': 0.002 HIVE, 'sbi2': 0.008 HIVE,
        'zcool': 0.000 HIVE, 'hivehq': 0.002 HIVE, 'rowdiya': 0.000 HIVE, 'qurator-tier-1-2': 0.012 HIVE
    }
}
get_parent(children=None)

Returns the parent post with depth == 0

get_reblogged_by(identifier=None)

Shows in which blogs this post appears

get_replies(raw_data=False, identifier=None)

Returns content replies

Parameters

raw_data (bool) – When set to False, the replies will be returned as Comment class objects

get_rewards()

Returns the total_payout, author_payout and the curator payout in HBD. When the payout is still pending, the estimated payout is given out.

Note

Potential beneficiary rewards were already deducted from the author_payout and the total_payout

Example::

{
    'total_payout': 9.956 HBD,
    'author_payout': 7.166 HBD,
    'curator_payout': 2.790 HBD
}
get_vote_with_curation(voter=None, raw_data=False, pending_payout_value=None)

Returns vote for voter. Returns None, if the voter cannot be found in active_votes.

Parameters
  • voter (str) – Voter for which the vote should be returned

  • raw_data (bool) – If True, the raw data are returned

  • pending_payout_HBD (float, str) – When not None this value instead of the current value is used for calculating the rewards

get_votes(raw_data=False)

Returns all votes as ActiveVotes object

property id
is_comment()

Returns True if post is a comment

is_main_post()

Returns True if main post, and False if this is a comment (reply).

is_pending()

Returns if the payout is pending (the post/comment is younger than 7 days)

json()
property json_metadata
property parent_author
refresh()
rehive(identifier=None, account=None)

Rehive a post

Parameters
  • identifier (str) – post identifier (@<account>/<permlink>)

  • account (str) – (optional) the account to allow access to (defaults to default_account)

reply(body, title='', author='', meta=None)

Reply to an existing post

Parameters
  • body (str) – Body of the reply

  • title (str) – Title of the reply post

  • author (str) – Author of reply (optional) if not provided default_user will be used, if present, else a ValueError will be raised.

  • meta (json) – JSON meta object that can be attached to the post. (optional)

property reward

Return the estimated total HBD reward.

time_elapsed()

Returns a timedelta on how old the post is.

property title
type_id = 8
upvote(weight=100, voter=None)

Upvote the post

Parameters
  • weight (float) – (optional) Weight for posting (-100.0 - +100.0) defaults to +100.0

  • voter (str) – (optional) Voting account

vote(weight, account=None, identifier=None, **kwargs)

Vote for a post

Parameters
  • weight (float) – Voting weight. Range: -100.0 - +100.0.

  • account (str) – (optional) Account to use for voting. If account is not defined, the default_account will be used or a ValueError will be raised

  • identifier (str) – Identifier for the post to vote. Takes the form @author/permlink.

class bhive.comment.RecentByPath(path='promoted', category=None, lazy=False, full=True, hive_instance=None)

Bases: list

Obtain a list of votes for an account

Parameters
  • account (str) – Account name

  • hive_instance (Hive) – Hive() instance to use when accesing a RPC

class bhive.comment.RecentReplies(author, skip_own=True, lazy=False, full=True, hive_instance=None)

Bases: list

Obtain a list of recent replies

Parameters
  • author (str) – author

  • skip_own (bool) – (optional) Skip replies of the author to him/herself. Default: True

  • hive_instance (Hive) – Hive() instance to use when accesing a RPC