def setUpClass(cls): cls.bts = Hive(node=get_hive_nodes(), nobroadcast=True, keys={"active": wif}, num_retries=10) # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_blockchain_instance(cls.bts) cls.bts.set_default_account("test") acc = Account("fullnodeupdate", blockchain_instance=cls.bts) n_votes = 0 index = 0 entries = acc.get_blog(limit=20)[::-1] while n_votes == 0: comment = Comment(entries[index], blockchain_instance=cls.bts) votes = comment.get_votes() n_votes = len(votes) index += 1 last_vote = votes[0] cls.authorpermvoter = construct_authorpermvoter( last_vote['author'], last_vote['permlink'], last_vote["voter"]) [author, permlink, voter] = resolve_authorpermvoter(cls.authorpermvoter) cls.author = author cls.permlink = permlink cls.voter = voter cls.authorperm = construct_authorperm(author, permlink)
def setUpClass(cls): nodelist = NodeList() cls.bts = Hive( node=nodelist.get_hive_nodes(), nobroadcast=True, num_retries=10 ) set_shared_blockchain_instance(cls.bts)
def start(self, authorperm=None, file=None): self.main_window = Tk() self.main_window.title('HiveDiff') self.__main_window_ui = MainWindowUI(self.main_window) self.leftFile = '' self.rightFile = '' self.authorperm = '' self.__main_window_ui.center_window() self.__main_window_ui.create_file_path_labels() self.__main_window_ui.create_text_areas() self.__main_window_ui.create_search_text_entry(self.__findNext) self.__main_window_ui.create_line_numbers() self.__main_window_ui.create_scroll_bars() self.__main_window_ui.create_file_treeview() path_to_my_project = os.getcwd() self.__main_window_ui.add_menu('File', [ {'name': 'Compare Markdown file', 'command': self.__browse_files}, {'name': 'View Post history', 'command': self.__enter_post}, {'name': 'Compare Markdown files in Directory', 'command': self.__browse_directories}, {'name': 'Reload', 'command': self.__reload, 'accelerator': 'Ctrl+R'}, {'separator'}, {'name': 'Exit', 'command': self.__exit, 'accelerator': 'Alt+F4'} ]) self.__main_window_ui.add_menu('Edit', [ {'name': 'Find', 'command': self.__startFindText, 'accelerator': 'Ctrl+F'}, {'separator'}, {'name': 'Cut', 'command': self.__cut, 'accelerator': 'Ctrl+X'}, {'name': 'Copy', 'command': self.__copy, 'accelerator': 'Ctrl+C'}, {'name': 'Paste', 'command': self.__paste, 'accelerator': 'Ctrl+P'}, {'separator'}, {'name': 'Go To Line', 'command': self.__goToLine, 'accelerator': 'Ctrl+G'} ]) self.__main_window_ui.add_menu('Help', [ {'name': 'About', 'command': self.__about}, ]) self.__main_window_ui.fileTreeView.bind('<<TreeviewSelect>>', lambda *x:self.treeViewItemSelected()) nodelist = NodeList() nodelist.update_nodes() hive = Hive(node=nodelist.get_hive_nodes()) set_shared_blockchain_instance(hive) self.leftFile = '' self.rightFile = file if file else '' self.filesChanged() if authorperm != '' and authorperm is not None: self.authorperm = authorperm self.__resolve_authorperm() self.__bind_key_shortcuts() self.main_window.mainloop()
def setUpClass(cls): cls.bts = Steem( node=get_hive_nodes(), nobroadcast=True, num_retries=10 ) set_shared_blockchain_instance(cls.bts) cls.asset = Asset("HBD") cls.symbol = cls.asset["symbol"] cls.precision = cls.asset["precision"] cls.asset2 = Asset("HIVE")
def setUpClass(cls): cls.bts = Hive( node=get_hive_nodes(), nobroadcast=True, bundle=False, unsigned=True, # Overwrite wallet to use this list of wifs only keys={"active": wif}, num_retries=10) cls.account = Account("beembot", steem_instance=cls.bts) set_shared_blockchain_instance(cls.bts)
def setUpClass(cls): cls.bts = Steem(node=get_hive_nodes(), nobroadcast=True, keys={"active": wif}, num_retries=10) b = Blockchain(blockchain_instance=cls.bts) num = b.get_current_block_num() cls.start = num - 5 cls.stop = num # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_blockchain_instance(cls.bts)
def __init__(self, username): self.username = username self.account = None self.witness = 0 self.nodes = [ 'https://rpc.blurt.buzz', # 'https://blurtd.privex.io', # 'https://rpc.blurtworld.com', # 'https://rpc.blurt.world', # 'https://api.softmetal.xyz', ] random.shuffle(self.nodes) self.blurt = Blurt(node=self.nodes) self.blockchain = set_shared_blockchain_instance(self.blurt) # Get a reference to the database service self.firebase = firebase.database() # Create account object try: self.account = Account(self.username, full=False, lazy=False) except Exception as e: self.username = None self.account = None print(f'AccountDoesNotExistsException : {e}') # Witness check try: Witness(self.username) self.witness = 1 except Exception: self.witness = 0
def set_node_list(chain_type=None): nodelist = NodeList() nodelist.update_nodes() chain = None if chain_type == 'steemit': steem_nodes = nodelist.get_steem_nodes() chain = Steem(node=steem_nodes) chain.set_default_nodes(steem_nodes) elif chain_type == 'hive': nodelist = NodeList() nodelist.update_nodes() hive_nodes = nodelist.get_hive_nodes() chain = Hive(node=hive_nodes) chain.set_default_nodes(hive_nodes) set_shared_blockchain_instance(chain) return chain
def setUpClass(cls): node_list = get_hive_nodes() cls.stm = Hive(node=node_list, keys={ "active": wif, "owner": wif2, "memo": wif3 }, nobroadcast=True, num_retries=10) cls.steemit = Hive(node="https://api.steemit.com", nobroadcast=True, keys={ "active": wif, "owner": wif2, "memo": wif3 }, num_retries=10) set_shared_blockchain_instance(cls.stm) cls.stm.set_default_account("test")
def get_node(): random.shuffle(nodes) for node in nodes: try: response = requests.get(node, timeout=1) if response: return node except requests.exceptions.RequestException as e: print(f'GET_NODE_ERR:{node} {e}') COMMUNITY_ACTIVE_KEY = os.environ.get('COMMUNITY_ACTIVE_KEY') COMMUNITY_NAME = os.environ.get('COMMUNITY_NAME') STEEM = Steem(node=get_node(), keys=[COMMUNITY_ACTIVE_KEY]) set_shared_blockchain_instance(STEEM) # Firebase configuration serviceAccountCredentials = json.loads( base64.b64decode(os.environ.get('FB_SERVICEACCOUNT').encode()).decode()) firebase_config_prd = { "apiKey": os.environ.get('FB_APIKEY'), "authDomain": os.environ.get('FB_AUTHDOMAIN'), "databaseURL": os.environ.get('FB_DATABASEURL'), "storageBucket": os.environ.get('FB_STORAGEBUCKET'), "serviceAccount": serviceAccountCredentials, } firebase = pyrebase.initialize_app(firebase_config_prd) # Get a reference to the database service
import os import re import random import json import datetime from beem import Hive from beem.account import Account from beem.blockchain import Blockchain from beem.comment import Comment from beem.instance import set_shared_blockchain_instance from beem.utils import construct_authorperm hive = Hive(node=['https://anyx.io/'], keys=["Public Key"]) set_shared_blockchain_instance(hive) chain = Blockchain() print("Loading Bot") def summoncharbot(): print(f'[Starting Character Bot]') REGEX = '(?<=^|(?<=[^a-zA-Z0-9-.]))@([A-Za-z]+[A-Za-z0-9]+)' username = '******' REGCHA = '(?<=^|(?<=[^a-zA-Z0-9-.]))!([A-Za-z]+[A-Za-z0-9]+)' newchar = 'generate' while True: try: for post in chain.stream(opNames="comment", threading=True,
from beem.nodelist import NodeList from beem.account import Account from beem.comment import Comment from beem.discussions import Query from beem.discussions import Discussions from beem.instance import set_shared_blockchain_instance from beem.utils import construct_authorperm from markupsafe import Markup nodelist = NodeList() nodelist.update_nodes() #nodes = ["https://api.hive.blog", "https://anyx.io"] q = Query(limit=10) hv = Hive(node=nodelist.get_hive_nodes()) set_shared_blockchain_instance(hv) d = Discussions(blockchain_instance=hv) image_proxy = "https://images.hive.blog/480x0/" def strip(text): text['body'] = re.sub(r"(^https?:[^)''\"]+\.(?:jpg|jpeg|gif|png))", rf'![](\1) >', text['body']) text['body'] = markdown.markdown(text['body'], extensions=[ 'nl2br', 'codehilite', 'pymdownx.extra', 'pymdownx.magiclink', 'pymdownx.betterem', 'pymdownx.inlinehilite', 'pymdownx.snippets', 'pymdownx.striphtml']) text['body'] = re.sub("(<h1>|<h2>)", "<h3>", text['body']) text['body'] = re.sub(r"<img\b(?=\s)(?=(?:[^>=]|='[^']*'|=\"[^\"]*\"|=[^'\"][^\s>]*)*?\ssrc=['\"]([^\"]*)['\"]?)(?:[^>=]|='[^']*'|=\"[^\"]*\"|=[^'\"\s]*)*\"\s?\/?>", rf'<img src={image_proxy}\1 >', text['body']) text['body'] = Markup(text['body']) return text
def __init__(self): super(QMainWindow, self).__init__() # Set up the user interface from Designer. self.setupUi(self) self.setAccessibleName("Hive Desktop") self.redrawLock = Lock() self.updateLock = Lock() self.optionsDialog = dialogs.Options(self) self.aboutDialog = dialogs.About(self, copyright='holger80', programName='Hive Desktop', version=VERSION, website='https://github.com/holgern/hivedesktop', websiteLabel='Github', comments='"Welcome to Hive desktop!\n This is the first release for testing qt5.\n Please vote for holger80 as witness, if you like this :).', licenseName='GPL-3.0', # licenseUrl=helpers.joinpath_to_cwd('LICENSE').as_uri(), authors=('holger80',), # dependencies=[l.strip() for l in requirements.readlines()], ) self.mdrenderer = MDRenderer(str(helpers.joinpath_to_cwd('themes'))) # tmpfile = helpers.mktemp(prefix='hivedesktop', suffix='.html') self.post = {"body": "##test", "authorperm": "@test/test"} self.thread = threads.MDThread(self) # self.webview.url = tmpfile.as_uri() self.feedListWidget.currentRowChanged.connect(self.change_displayed_post, Qt.QueuedConnection) self.timer = QTimer() self.timer.timeout.connect(self.refresh_account_thread) self.timer2 = QTimer() self.timer2.timeout.connect(self.update_account_hist_thread) self.timer3 = QTimer() self.timer3.timeout.connect(self.update_account_feed_thread) self.cache_path = QStandardPaths.writableLocation(QStandardPaths.CacheLocation) self.db_type = "shelve" self.db_type = "sqlite" self.feed = [] self.post = None # Get settings settings = QSettings() # Get checkbox state with speciying type of checkbox: # type=bool is a replacement of toBool() in PyQt5 check_state = settings.value(SETTINGS_TRAY, True, type=bool) hist_info_check_state = settings.value(SETTINGS_HIST_INFO, True, type=bool) account_state = settings.value(SETTINGS_ACCOUNT, "", type=str) self.resize(settings.value(SETTINGS_SIZE, QSize(1053, 800))) self.move(settings.value(SETTINGS_POS, QPoint(50, 50))) #self.accountHistTableWidget.setColumnCount(5) #self.accountHistTableWidget.setHorizontalHeaderLabels(["type", "1", "2", "3", "timestamp"]) self.update_account_refreshtime = 5000 # Set state self.accountHistNotificationCheckBox.setChecked(hist_info_check_state) self.autoRefreshCheckBox.setChecked(check_state) if check_state: self.timer.start(self.update_account_refreshtime) self.timer2.start(15000) self.timer3.start(60000) self.accountLineEdit.setText(account_state) # connect the slot to the signal by clicking the checkbox to save the state settings self.autoRefreshCheckBox.clicked.connect(self.save_check_box_settings) self.accountHistNotificationCheckBox.clicked.connect(self.save_check_box_settings) self.accountLineEdit.editingFinished.connect(self.save_account_settings) self.actionAbout.triggered.connect(self.about) self.actionOptions.triggered.connect(self.options) self.threadpool = QThreadPool() self.minimizeAction = QAction("Mi&nimize", self, triggered=self.hide) self.maximizeAction = QAction("Ma&ximize", self, triggered=self.showMaximized) self.restoreAction = QAction("&Restore", self, triggered=self.showNormal) menu = QMenu() menu.addAction(self.minimizeAction) menu.addAction(self.maximizeAction) menu.addAction(self.restoreAction) menu.addSeparator() # aboutAction = menu.addAction("about") # aboutAction.triggered.connect(self.about) exitAction = menu.addAction("Exit") exitAction.triggered.connect(self.closeApp) self.tray = QSystemTrayIcon(QIcon(':/icons/icon.ico')) self.tray.setContextMenu(menu) self.tray.activated.connect(self.trayAction) self.tray.setToolTip("Hive Desktop!") self.tray.setObjectName("Hive Desktop") self.setWindowTitle("Hive Desktop") self.tray.show() splash_pix = QPixmap(':/icons/splash.png') splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint) splash.setEnabled(False) #splash.show() #splash.showMessage("<h1><font color='green'>starting...</font></h1>", Qt.AlignTop | Qt.AlignCenter, Qt.black) account = account_state nodelist = NodeList() nodelist.update_nodes() self.stm = Steem(node=nodelist.get_nodes(hive=True)) set_shared_blockchain_instance(self.stm) if account != "": try: self.hist_account = Account(account, steem_instance=self.stm) except: self.hist_account = None else: self.hist_account = None self.refreshPushButton.clicked.connect(self.refresh_account) self.refreshPushButton.clicked.connect(self.update_account_hist_thread) self.accountLineEdit.editingFinished.connect(self.update_account_info) if self.hasFocus is not None: self.init_new_account() self.init_new_blocks() splash.deleteLater()