def me(self, network, name): am = AccountManager() account = am.get(network, name) controller = account.controller() print '{0} account {1} Me:'.format(network, name) user = controller.me() print user
def deleteAccount(self, network, name): account = Account.getAccount(network, name) am = AccountManager() if account and am.remove(account): print 'Delete {0} account {1} : OK'.format(network, name) else: print 'Delete {0} account {1} : FAIL'.format(network, name)
def userTimeline(self, network, name, id, limit): am = AccountManager() account = am.get(network, name) controller = account.controller() print '{0} account {1} User Timeline:'.format(network, name) for note in controller.userTimeline(id, int(limit)): print note
def unlike(self, network, name, id): am = AccountManager() account = am.get(network, name) controller = account.controller() note = Note(id, None, None, None) res = controller.unlike(note) print '{0} account {1} Unlike: {2}'.format(network, name, 'Error' if not res else 'OK - ID: ' + note.id)
def post(self, network, name, message): am = AccountManager() account = am.get(network, name) controller = account.controller() note = Note(None, None, None, message) res = controller.post(note) print '{0} account {1} Post: {2}'.format(network, name, 'Error' if not res else 'OK - ID: ' + note.id)
def unblock(self, network, name, id): am = AccountManager() account = am.get(network, name) controller = account.controller() user = User(id) res = controller.unblock(user) print '{0} account {1} Unblock: {2}'.format(network, name, 'Error' if not res else 'OK - ID: @' + user.id)
def followers(self, network, name): am = AccountManager() account = am.get(network, name) controller = account.controller() print '{0} account {1} Followers:'.format(network, name) for user in controller.followers(): print user
def sentMessages(self, network, name): am = AccountManager() account = am.get(network, name) controller = account.controller() print '{0} account {1} Sent Messages:'.format(network, name) for message in controller.sentMessages(): print message
def user(self, network, name, id): am = AccountManager() account = am.get(network, name) controller = account.controller() print '{0} account {1} User:'.format(network, name) user = controller.user(id) print user
def sendMessage(self, network, name, id, msg): am = AccountManager() account = am.get(network, name) controller = account.controller() receiver = controller.user(id) message = Note(None, receiver, None, msg) res = controller.sendMessage(message) print '{0} account {1} Send Message: {2}'.format(network, name, 'Error' if not res else 'OK - ID: ' + message.id)
def listAccounts(self, network): am = AccountManager() accounts = am.getAll() if network is None else am.getAllByNetwork(network) print 'Account List:' if len(accounts) == 0: print 'Empty' return k = 1 for account in accounts: print '\t[{0}] {1} account {2}'.format(k, account.network, account.name) k += 1
def createAccount(self, network, name): account = Account.getAccount(network, name) am = AccountManager() if account and am.create(account): print 'Create {0} account {1} : OK'.format(network, name) accountType = Account.networkToAccount(network) callback = None if accountType == 'OAuth': callback = self.enterOAuthVerifier elif accountType == 'UserPass': callback = self.enterUserPass if callback and am.register(account, callback): print 'Register {0} account {1} : OK'.format(network, name) else: print 'Register {0} account {1} : FAIL'.format(network, name) am.remove(account) else: print 'Create {0} account {1} : FAIL'.format(network, name)