def commandTip(self, command): """ Tip a nickname, address or post_id nickname tipping still in progress """ if not util.checkLogin(self): return elif len(command) < 2: self.writeConsole('You need to supply the detail of the agent or post you wish to tip.') return #command[1] could be an address, a nickname or a post id #we can identify addresses so do that first if util.isAddress(command[1]): #we know it's an address tipAddress = command[1] postId = None #otherwise test for nickname elif util.getAddressFromNick(command[1]) is not False: tipAddress = util.getAddressFromNick(command[1]) postId = None #all it can be after that is a post id else: tipAddress = util.getAddressFromPostID(self, command[1]) if tipAddress is False: self.writeConsole('Tip Failed - ' + command[1] + ' was not a nickname, address or post id') return postId = command[1] try: response = self.agent.tip(tipAddress, netvend.convert_value(int(self.tipAmount), str(self.unit), 'usat'), postId) if response['success'] == 1: try: self.agentBalance = self.agent.fetch_balance() except netvend.NetvendResponseError as e: self.agentBalance = 0 self.writeConsole( 'Tip successful.\nTip ID : ' + str(response['command_result']) + ' - New Balance : ' + str( self.agentBalance)) else: self.writeConsole('Tip Failed') return except netvend.NetvendResponseError as e: self.writeConsole('Tip failed - ' + str(e)) return
def commandFollow(self, command): """ Follow the specified agent can specify address or nick update the list of nicks first """ if not util.checkLogin(self): return if len(command) < 2: self.writeConsole('You need to specify an agent to follow') return #update nicknames if util.pollAllPosts(self): util.checkNewNicks(self) conn = db.open() c = conn.cursor() if util.isAddress(command[1]): query = "select address from accounts where address = '" + command[1] + "';" rows = util.putQuery(self, query) if rows is False: self.writeConsole('Couldn\'t find agent ' + command[1]) return address = command[1] nick = util.getNick(self, address) else: c.execute('select address from nicks where nick=?;', (command[1],)) address = c.fetchone() if address is None: self.writeConsole('Couldn\'t find agent ' + command[1]) return address = address[0] nick = command[1] c.execute("select id from follows where address = ?;", (str(address),)) id = c.fetchone() if id is None: c.execute("insert into follows (nick, address, profile) values (?,?,?);", (str(nick), str(address), str(self.agentAddress))) else: c.execute("update follows set nick=? where address=? and profile=?;", (str(nick), str(address), str(self.agentAddress))) db.close(conn) self.writeConsole('You are now following ' + nick) return