Esempio n. 1
0
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 self.agent is None:
		self.writeConsole('You don\'t have an active agent.\n/add an agent or /login in order to view history.') 
		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:
			post = row[1]
		self.writeConsole('Post ID: ' + str(row[0]) + ' Fee: ' + str(row[2]) + '\n>> ' + str(post) + '\n')
	return
Esempio n. 2
0
def commandFollow(self, command):
    """
		Follow the specified agent
		can specify address or nick
		update the list of nicks first
	"""
    if self.agent is None:
        self.writeConsole(
            'You don\'t have an active agent.\n/add an agent or /login in order to follow agents.'
        )
        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 = sqlite3.connect('coinflow.db')
    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, account) values (?,?,?);",
            (str(nick), str(address), str(self.agentAddress)))
    else:
        c.execute("update follows set nick=? where address=? and account=?;",
                  (str(nick), str(address), str(self.agentAddress)))
    conn.commit()
    conn.close()
    self.writeConsole('You are now following ' + nick)
    return
Esempio n. 3
0
def commandFollow(self, command):
	"""
		Follow the specified agent
		can specify address or nick
		update the list of nicks first
	"""
	if self.agent is None:
		self.writeConsole('You don\'t have an active agent.\n/add an agent or /login in order to follow agents.') 
		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 = sqlite3.connect('coinflow.db')
	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, account) values (?,?,?);", (str(nick), str(address), str(self.agentAddress)))
	else:
		c.execute("update follows set nick=? where address=? and account=?;", (str(nick), str(address), str(self.agentAddress)))
	conn.commit()
	conn.close()
	self.writeConsole('You are now following ' + nick)
	return
Esempio n. 4
0
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 self.agent is None:
        self.writeConsole(
            'You don\'t have an active agent.\n/add an agent or /login in order to view history.'
        )
        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:
            post = row[1]
        self.writeConsole('Post ID: ' + str(row[0]) + ' Fee: ' + str(row[2]) +
                          '\n>> ' + str(post) + '\n')
    return