Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
    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
Ejemplo n.º 8
0
    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
Ejemplo n.º 9
0
    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
Ejemplo n.º 10
0
    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)
Ejemplo n.º 11
0
    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
Ejemplo n.º 12
0
    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)