Exemple #1
0
    def test_login_url(self):
        bts = self.bts
        sc2 = SteemConnect(steem_instance=bts)
        url = sc2.get_login_url("localhost", scope="login,vote")
        url_test = 'https://steemconnect.com/oauth2/authorize?client_id=None&redirect_uri=localhost&scope=login,vote'
        self.assertEqual(len(url), len(url_test))
        self.assertEqual(len(url.split('?')), 2)
        self.assertEqual(url.split('?')[0], url_test.split('?')[0])

        url_parts = (url.split('?')[1]).split('&')
        url_test_parts = (url_test.split('?')[1]).split('&')

        self.assertEqual(len(url_parts), 3)
        self.assertEqual(len(list(set(url_parts).intersection(set(url_test_parts)))), 3)
Exemple #2
0
    def test_transfer(self):
        bts = self.bts
        acc = self.account
        acc.steem.txbuffer.clear()
        tx = acc.transfer(
            "test1", 1.000, "STEEM", memo="test")
        sc2 = SteemConnect(steem_instance=bts)
        url = sc2.url_from_tx(tx)
        url_test = 'https://steemconnect.com/sign/transfer?from=test&to=test1&amount=1.000+STEEM&memo=test'
        self.assertEqual(len(url), len(url_test))
        self.assertEqual(len(url.split('?')), 2)
        self.assertEqual(url.split('?')[0], url_test.split('?')[0])

        url_parts = (url.split('?')[1]).split('&')
        url_test_parts = (url_test.split('?')[1]).split('&')

        self.assertEqual(len(url_parts), 4)
        self.assertEqual(len(list(set(url_parts).intersection(set(url_test_parts)))), 4)
Exemple #3
0
def send_message(card_detail_id, market_id, second_min, edition, is_gold,
                 card_uid, seller, bcx, level, card_price, percent):
    if second_min > 0.05:
        r = requests.get("https://steemmonsters.com/cards/get_details").json()
        for i in r:
            if i['id'] == int(card_detail_id):
                name = i['name']
                break
        if edition == 0:
            edition_txt = "Alpha"
        elif edition == 1:
            edition_txt = "Beta"
        elif edition == 2:
            edition_txt = "Promo"
        elif edition == 3:
            edition_txt = "Reward"
        else:
            edition_txt = "Untamed"
        price_info_json = requests.get(
            "https://steemmonsters.com/settings").json()
        sbd_price = price_info_json['sbd_price'] - 0.02
        steem_price = price_info_json['steem_price'] - 0.01
        dec_price = price_info_json['dec_price']
        dec_send = round(card_price / dec_price, 3)
        sbd_send = round(card_price / sbd_price, 3)
        stmc_sbd = str(sbd_send) + " SBD"
        steem_send = round(card_price / steem_price, 3)
        stmc_steem = str(steem_send) + " STEEM"
        dec = """["custom_json",{"required_auths":["__signer"],"required_posting_auths":[],"id":"sm_market_purchase","json":"{\\"items\\":[\\"@\\"],\\"purchaser\\":\\"__signer\\",\\"market\\":\\"svirus\\"}"}]"""
        dec = dec.split("@")
        dec = dec[0] + market_id + dec[1]
        encoded_dec = base64.b64encode(bytes(dec, "utf-8"))
        string = encoded_dec.decode("utf-8")
        final_dec = f"https://beta.steemconnect.com/sign/op/{string.replace('=', '.')}?authority=active"
        memo = "sm_market_purchase:{}".format(market_id)
        stmconnect = SteemConnect()
        steem_link = stmconnect.create_hot_sign_url("transfer", {
            "to": "svirus",
            "amount": stmc_steem,
            "memo": memo
        })
        sbd_link = stmconnect.create_hot_sign_url("transfer", {
            "to": "svirus",
            "amount": stmc_sbd,
            "memo": memo
        })
        thumbnail_link = thumbnail_generator(edition, name, is_gold)
        embed = Embed(color=15105817, timestamp='now')
        if bcx == 1:
            embed.set_thumbnail(thumbnail_link)
            embed.set_author(f"{name}\n{card_uid} by @{seller}")
            embed.set_title(
                f"Edition: {edition_txt}, Gold: {is_gold}, Bcx: {bcx}, Level: {level}\nPrice: {card_price}$, Cheaper: {percent}%, Second Lowest: {second_min}"
            )
            embed.add_field(
                name=".",
                value=
                f"Commands:\n**STEEM**: `..transfer {steem_send} steem svirus {memo}`\n**SBD**: `..transfer {sbd_send} sbd svirus {memo}`\n\nSteemconnect:\n[{steem_send} STEEM]({steem_link})\n[{sbd_send} SBD]({sbd_link})\n[{dec_send} DEC]({final_dec})\n\n**Verify**: `..verify {market_id}`"
            )
        else:
            one_card_price = round(card_price / bcx, 3)
            embed.set_thumbnail(thumbnail_link)
            embed.set_author(f"{name}\n{card_uid} by @{seller}")
            embed.set_title(
                f"Edition: {edition_txt}, Gold: {is_gold}, Bcx: {bcx}, Level: {level}\nPrice: {card_price}$, Per bcx: {one_card_price}$, Cheaper: {percent}%, Second Lowest: {second_min}"
            )
            embed.add_field(
                name=".",
                value=
                f"Commands:\n**STEEM**: `..transfer {steem_send} steem svirus {memo}`\n**SBD**: `..transfer {sbd_send} sbd svirus {memo}`\n\nSteemconnect:\n[{steem_send} STEEM]({steem_link})\n[{sbd_send} SBD]({sbd_link})\n[{dec_send} DEC]({final_dec})\n\n**Verify**: `..verify {market_id}`"
            )
        try:
            if percent > 40:
                fhook.send(embed=embed)
                fhook.close()
            elif bcx > 1:
                mhook.send(embed=embed)
                mhook.close()
            elif is_gold is True:
                ghook.send(embed=embed)
                ghook.close()
            elif edition == 0:
                ahook.send(embed=embed)
                ahook.close()
            elif edition == 4:
                uhook.send(embed=embed)
                uhook.close()
            else:
                bhook.send(embed=embed)
                bhook.close()
        except:
            print(traceback.format_exc())
Exemple #4
0
from flask import Flask, request
from beem.steemconnect import SteemConnect
import getpass

app = Flask(__name__)

c = SteemConnect(client_id="beem.app",
                 scope="login,vote,custom_json",
                 get_refresh_token=False)
# replace test with our wallet password
wallet_password = getpass.getpass('Wallet-Password:'******'/')
def index():
    login_url = c.get_login_url("http://*****:*****@app.route('/welcome')
def welcome():
    access_token = request.args.get("access_token", None)
    name = request.args.get("username", None)
    if c.get_refresh_token:
        code = request.args.get("code")
        refresh_token = c.get_access_token(code)
        access_token = refresh_token["access_token"]
        name = refresh_token["username"]
    elif name is None:
        c.set_access_token(access_token)
Exemple #5
0
#!/usr/lib/python
from flask import Flask, request
from beem.steemconnect import SteemConnect
import getpass

app = Flask(__name__)

c = SteemConnect(
    client_id="drugwars.app",
    scope=
    "vote,comment,delete_comment,comment_options,custom_json,claim_reward_balance"
)
# replace test with our wallet password
wallet_password = getpass.getpass('Wallet-Password:'******'/')
def index():
    login_url = c.get_login_url("https://drugwars.io/login", )
    return "<a href='%s'>Login with SteemConnect</a>" % login_url


@app.route('/welcome')
def welcome():
    access_token = request.args.get("access_token", None)
    name = request.args.get("username", None)
    if c.get_refresh_token:
        code = request.args.get("code")
        refresh_token = c.get_access_token(code)