Unfollow Everything!

in steem-python •  7 years ago 

I did an early spring cleaning yesterday.
Unfollowing all 3000 followees..followingers..fellowship..users I do follow.
And I had to do it by force. I did write a nice script, but that didn't work.
Instead, brute force:

from steem import Steem
from steem.commit import Commit
from steem.account import Account

username='isnochys'
s = Steem()
c = Commit(s)
aac = Account(username,s)
exp = aac.export()
fl = exp['following']
for fol in fl:
    c.unfollow(unfollow=fol, account=username)

That is a really awfull script.
But it worked.

I had something else in my mind, when I first got spring cleaning in my head:

from steem import Steem
from steem.commit import Commit
from steem.account import Account
from steem.transactionbuilder import TransactionBuilder
from steembase import operations

username='isnochys'
s = Steem()
c = Commit(s)
aac = Account(username,s)
exp = aac.export()
fl = exp['following']
unfol=[]
for fol in fl:
    required_auths=[]
    required_posting_auths =[username]
    id = 'follow'
    json = ["follow",{"follower":username,"following":fol,"what":[]}]
    mdi = {"required_auths": required_auths,'required_posting_auths':required_posting_auths,'id':id,'json':json}
    unfol.append(mdi)

tb = TransactionBuilder()
operation = [operations.CustomJson(**x) for x in unfol]
tb.appendOps(operation)
tb.appendSigner(username, 'posting')
tb.sign()
tx = tb.broadcast()

This would have been way more elegant.
But I tried and failed with:

InsufficientAuthorityError

I have no idea, why it didn't work.
I looked into steemd.py and other linked files. The unfollow command does exactly the same, as I did in the transaction builder.
Well, I got my unfollowing. It just took a bit longer.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

InsufficientAuthorityError

That seems to give the idea that you didn't adress the right authorization keys.

Are you sure you gave the 'posting key' with it?

To quote steemd.py for def sign:

param string wifs: One or many wif keys to use for signing
                a transaction. If not present, the keys will be loaded
                from the wallet as defined in "missing_signatures" key
                of the transactions.

it is signed successfully, it gets the key from my wallet. It worked with no_broadcast=True.
And the error occurs in tb.broadcast()
Also, previous tests with different operations(but with active key, to be true) worked with no_broadcast=False
Anyway, what's done is done;)

This post has been upvoted by @microbot with 18.1%!
Vote for my creator @isnochys as witness!