def commandHistory(self, command): """ Display the last ten posts for the specified user the users current agents posts are shown if no address/nick is given """ if not util.checkLogin(self): return if len(command) < 2: address = self.agentAddress nick = self.agentNick else: address = util.getAddressFromNick(command[1]) if address is False: address = command[1] nick = command[1] else: address = address nick = command[1] self.writeConsole('\n== Last 10 Posts for ' + nick + ' ==\n') query = "select posts.post_id, posts.data, history.fee from posts inner join history on posts.history_id = history.history_id where posts.address = '" + str( address) + "' order by posts.ts asc limit 10" rows = util.putQuery(self, query) if rows is False: self.writeConsole('No posts to display') return for row in rows['rows']: if 'post:' in row[1]: post = row[1].split(':', 1)[1] else: continue self.writeConsole('Post ID: ' + str(row[0]) + ' Fee: ' + str(row[2]) + '\n>> ' + str(post) + '\n') return
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