示例#1
0
def tip(msg, user_id):
    """
    either tips a person a random amount or tips them x seckc coins
    :param msg: <person recieving tip> <random x y | x>
    :param user_id: the id of the user doing the tipping
    """
    msg = parse(msg)
    if msg is None: #no target user
        return ("error", "")
    form = {
        'user_id': user_id,
        'target_user': msg[0],
        'balance': get_balance(user_id),
        'amount': set_amount(msg[1:]),
    }
    if form["amount"] is None: #we recieved a non-int
        return ("error", "")
    form['transaction'] = make_transaction(user_id, form['target_user'], form['amount'])
    form['user_address'] = get_address(user_id)
    form['target_user_address'] = get_address(form['target_user'])
    form['user_balance'] = get_balance(user_id)
    form['target_user_balance'] = get_balance(form['target_user'])
    ############# fill out data
    tip_attachment = json.dumps([{
        "fallback":"<@{user_id}> tipped <@{target_user}> {amount} :SKC:".format(**form),
        "color": "good",
        "author_name": "SecKCoin Bank and Trust",
        "footer": "Please note: Transactions require at least one block confirmation in order to appear (Up to 5 minutes)",
        "fields": [
            {
                "title": ":skc: Transaction Hash:",
                "value": form['transaction'],
                "short": False
            },
            {
                "title": "From: ",
                "value": """<@{user_id}>
<https://seckco.in/address/{user_address}|{user_address}>
Current Balance: {user_balance}""".format(**form),
                "short": True
            },
            {
                "title": "To: ",
                "value": """<@{target_user}>
<https://seckco.in/address/{target_user_address}|{target_user_address}>
Current Balance: {target_user_balance}""".format(**form),
                "short": True
            }
        ]}], indent=4)

    currency_icon = ":skc:"
    tip_pretext = ":money_with_wings:"
    tip_posttext = " (View transaction on <https://seckco.in/tx/%s|https://seckco.in>)" % form['transaction']
    tip_message = "%s <@%s> => <@%s> %s %s %s" % (tip_pretext, user_id,
                                                  form['target_user'], form['amount'],
                                                  currency_icon, tip_posttext)

    return (tip_message, tip_attachment)
示例#2
0
文件: bus.py 项目: XueWei/ibus
    def __init__(self):
        super(Bus, self).__init__()
        self.__dbusconn = dbus.connection.Connection(common.get_address())
        self.__dbus = self.__dbusconn.get_object(dbus.BUS_DAEMON_NAME,
                                                 dbus.BUS_DAEMON_PATH)
        self.__unique_name = self.hello()
        self.__ibus = self.__dbusconn.get_object(common.IBUS_SERVICE_IBUS,
                                                 common.IBUS_PATH_IBUS)

        self.__dbusconn.call_on_disconnection(self.__dbusconn_disconnected_cb)
示例#3
0
    def __init__(self):
        super(Bus, self).__init__()
        self.__dbusconn = dbus.connection.Connection(common.get_address())
        _dbus = self.__dbusconn.get_object(dbus.BUS_DAEMON_NAME,
                                           dbus.BUS_DAEMON_PATH)
        self.__dbus = dbus.Interface (_dbus, dbus_interface="org.freedesktop.DBus")
        self.__unique_name = self.hello()

        _ibus = self.__dbusconn.get_object(common.IBUS_SERVICE_IBUS,
                                           common.IBUS_PATH_IBUS)
        self.__ibus = dbus.Interface (_ibus, dbus_interface='org.freedesktop.IBus')
        self.__ibus.connect_to_signal("RegistryChanged", self.__registry_changed_cb)

        self.__dbusconn.call_on_disconnection(self.__dbusconn_disconnected_cb)
示例#4
0
def deposit(msg, user_id):
    """
    returns user address
    :param msg: msg - unused - should be blank
    :user_id: user's id - used to get the wallet address and for flavor text
    """
    form = {
        'user_id': user_id,
        'user_address': get_address(user_id)
    }
    deposit_message = "<@{user_id}> your :skc: address is: {user_address}".format(**form)
    deposit_attachment = json.dumps(
        [{"fallback": "https://seckco.in/qr/{user_address}".format(**form),
          "color" : "good",
          "author_name" : "SecKCoin Bank and Trust",
          "image_url" : "https://seckco.in/qr/{user_address}".format(**form),
         }])
    return (deposit_message,
            deposit_attachment)
示例#5
0
文件: bus.py 项目: XueWei/ibus
 def get_address(self):
     return common.get_address()