class User: def __init__(self, login="******", password="******"): self.steem_instance_ = Steem(node="wss://ws.testnet3.golos.io", rpcuser=login, rpcpassword=password) self.user_ = account.Account(account_name=login, steem_instance=self.steem_instance_) print(self.user_.get('name')) def get_posts(self, limit=10, sort="active", category=None, start=None): # list of dicts return self.steem_instance_.get_posts(limit=limit, sort=sort, category=category, start=start) # cause of Golos API doesnt work def get_user_posts(self): return self.steem_instance_.get_blog(self.user_.get('name')) def post(self, title, body, category=None, tags=[]): self.steem_instance_.post(title, body, author=self.user_.get('name'), category=category, tags=tags)
def post_to_golos(self, is_repeat_request=False): """ Method to post pages to Golos """ # steem = Steem(node=settings.NODE_URL, wif=settings.POSTING_KEY) steem = Steem( node='wss://ws.golos.io', wif='5JgEDJqUKLSK6sD2rCqaPxZ2YAyaxTXmcqmp14WtWJ2BCpFzh4o') try: if settings.POST_TO_BLOCKCHAIN: steem.post(title=self.title, body=self.build_body_for_golos(), author=settings.POST_AUTHOR, category=settings.POST_AUTHOR, meta=self.metadata) self.is_published = True except Exception as e: print(e) self.is_published = False if is_repeat_request: self.save()