main.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:CTPrivAPI 作者: doubleelforbes 项目源码 文件源码
def tip():
    global privapi
    currency = simpledialog.askstring("Currency Required", "Please provide the currency to tip in (eg. 'DOT' or '2')")
    if currency == "":
        debugout("ERROR! - Cannot tip without a currency!")
    else:
        amount = simpledialog.askfloat("Amount Required", "Please provide an amount of " + currency + " to tip")
        activeusers = simpledialog.askinteger("Number of Users Required",
                                              "Please provide a number of active users to tip (2-100):", initialvalue=2)
        formattedamount = "{0:.8f}".format(amount)
        activeusers = str(activeusers)
        confirm = messagebox.askokcancel("Confirm Tip", "Please confirm that you want to tip the trollbox\r\n" +
                                         "Tip Details:\r\nCurrency: " + currency + "\r\nAmount: " + formattedamount +
                                         "\r\nActive Users receiving: " + activeusers)
        if confirm:
            debugout("User confirmed " + formattedamount + " " + currency + " tip, to " + activeusers + " users.")
            response = privapi.submittip(currency, amount, activeusers)
            # The API is supposed to return a string in any event, it doesn't appear to be at the moment.
            # Just as well I coded my own confirmation!!
            if isinstance(response, str):
                # In this case, the response is always a string.
                debugout(response)
            else:
                # This next line is me getting over the fact that the API returns a Nonetype!!
                pass
                # debugout(str(response) + " is a " + str(type(response)))
        else:
            debugout("User Cancelled Tip after warning.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号