示例#1
0
                if not obj["recovery_account"] in accounts and not obj[
                        "recovery_account"] in extra:
                    extra.append(obj["recovery_account"])
                    opp3 = client.get_accounts([obj["recovery_account"]])
                    opp3.on_result(process_accounts)

            opp = client.get_accounts([account])
            opp.on_result(process_accounts)


mypath = os.path.dirname(os.path.realpath(__file__))
obs = textFileLogObserver(
    io.open(join(mypath, "watching_the_watchers.log"), "a"))
print "NOTE: asyncsteem logging to watching_the_watchers.log"
log = Logger(observer=obs, namespace="asyncsteem")
days = 8
if time.gmtime().tm_hour > 11:
    days = 7
bc = ActiveBlockChain(reactor,
                      rewind_days=days,
                      day_limit=1,
                      log=log,
                      nodelist="default",
                      stop_when_empty=True)
count = Count(mypath)
tb = TestBot(count)
bc.register_bot(tb, "testbot")
reactor.run()
count.dump()
print "DONE"
示例#2
0
        #For keeping track of if we are behind on the blockchain.
        self.cu.blocktime(tm)
        #Only process transfers to one single account, our owner.
        if to == self.account:
            self.cu.process_transfer(frm, memo)


#Get config with owner account name and unique unguessable secret
mypath = os.path.dirname(os.path.abspath(__file__))
with open(mypath + "/mini-auth.json") as configjsonfile:
    conf = json.load(configjsonfile)
secret = conf["secret"]
account = conf["account"]
#Set up logging
observer = textFileLogObserver(io.open(join(mypath, "mini-auth.log"), "a"))
logger = Logger(observer=observer, namespace="asyncsteem")
#Asyncsteem blochchain streamer
blockchain = ActiveBlockChain(reactor, log=logger, nodelist="default")
#Our CookieUtil is the main hub of our program
cu = CookieUtil(secret, logger)
#Instantiate our bot and link it to our blockchain
steembot = TransferStream(cu, account)
blockchain.register_bot(steembot, "flag_stream")
#Run our HTTP server on port 5080
root = MiniAuthWebServer(cu, account, reactor, logger)
factory = server.Site(root)
endpoint = endpoints.TCP4ServerEndpoint(reactor, 5080)
endpoint.listen(factory)
#Start twisted reactor.
reactor.run()
示例#3
0
import sys
sys.path.append('../')

from twisted.internet import reactor
from twisted.logger import Logger
from asyncsteem import ActiveBlockChain

log = Logger()


class DemoBot(object):
    def vote(self, tm, vote_event, client):
        w = vote_event["weight"]
        if w > 0:
            print("Vote by", vote_event["voter"], "for", vote_event["author"])
        else:
            if w < 0:
                print("Downvote by", vote_event["voter"], "for",
                      vote_event["author"])
            else:
                print("(Down)vote by", vote_event["voter"], "for",
                      vote_event["author"], "CANCELED")


bot = DemoBot()

blockchain = ActiveBlockChain(reactor, log)
blockchain.register_bot(bot, "demobot")
reactor.run()
from twisted.internet import reactor
from twisted.logger import Logger, textFileLogObserver
from asyncsteem import ActiveBlockChain
class Bot(object):
    def vote(self,tm,vote_event,client):
        opp = client.get_content(vote_event["author"],vote_event["permlink"])
        def process_vote_content(event, client):
            start_rshares = 0.0
            for vote in  event["active_votes"]:
                if vote["voter"] == vote_event["voter"] and vote["rshares"] < 0:
                    if start_rshares + float(vote["rshares"]) < 0:
                        print(vote["time"],\
                                "FLAG",\
                                vote["voter"],"=>",vote_event["author"],\
                                vote["rshares"]," rshares (",\
                                start_rshares , "->", start_rshares + float(vote["rshares"]) , ")")
                    else:
                        print(vote["time"],\
                                "DOWNVOTE",\
                                vote["voter"],"=>",vote_event["author"],\
                                vote["rshares"],"(",\
                                start_rshares , "->" , start_rshares + float(vote["rshares"]) , ")")
                start_rshares = start_rshares + float(vote["rshares"])
        opp.on_result(process_vote_content)
obs = textFileLogObserver(sys.stdout)
log = Logger(observer=obs,namespace="blockchain_test")
bc = ActiveBlockChain(reactor,log,rewind_days=1,nodelist="stage")
bot=Bot()
bc.register_bot(bot,"testbot")
reactor.run()
示例#5
0
            op = client.get_accounts(acclist)
            op.on_result(user_info)

        if vote_event["weight"] < 0:
            opp = client.get_content(vote_event["author"],
                                     vote_event["permlink"])
            opp.on_result(process_vote_content)
            al = list()
            if not vote_event["voter"] in self.looked_up:
                al.append(vote_event["voter"])
                self.looked_up.add(vote_event["voter"])
            if not vote_event["author"] in self.looked_up:
                al.append(vote_event["author"])
                self.looked_up.add(vote_event["author"])
            if len(al) > 0:
                lookup_accounts(al)

    def day(self, tm, event, client):
        self.wtw.report(tm)


obs = textFileLogObserver(io.open("watchingthewatchers.log", "a"))
print "NOTE: asyncsteem logging to watchingthewatchers.log"
log = Logger(observer=obs, namespace="asyncsteem")
bc = ActiveBlockChain(reactor, rewind_days=1, log=log, nodelist="stage")
wtw = WatchingTheWatchers()
tb = WatchingTheWatchersBot(wtw)
bc.register_bot(tb, "watchingthewatchers")
reactor.run()
示例#6
0
#!/usr/bin/python3

import sys

sys.path.append('../')

from twisted.internet import reactor
from twisted.logger import Logger
from asyncsteem import ActiveBlockChain

log = Logger()


class DemoBot(object):
    def comment(self, tm, comment_event, client):
        if comment_event['author'] == 'scottyeager':
            print('Comment by {} on post {} by {}:'.format(
                comment_event['author'], comment_event['parent_permlink'],
                comment_event['parent_author']))
            print(comment_event['body'])
            print()


bot = DemoBot()

blockchain = ActiveBlockChain(reactor, log, rewind_days=1)
blockchain.register_bot(bot, "demobot")
reactor.run()